Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom port does not work. #392

Open
laishulu opened this issue Nov 30, 2024 · 2 comments
Open

Custom port does not work. #392

laishulu opened this issue Nov 30, 2024 · 2 comments

Comments

@laishulu
Copy link

laishulu commented Nov 30, 2024

Prerequisites

Please answer the following questions for yourself before submitting an issue.

  • [Y] I am running the latest version
  • [Y] I checked the documentation and found no answer
  • [Y] I checked to make sure that this issue has not already been filed

Expected Behavior

work for chat.example.com:7777, not just chat.example.com

Current Behavior
the webpage can be loaded correctly,
but when I click create chat link,
it failed to create room link.

Failure Information
for server: chat.example.com:7777,
see error visiting: https://chat.example.com/api/chat-link
even CHAT_LINK_DOMAIN=https://chat.example.com:7777

Steps to Reproduce

click "create chat link" in the home page.

Context
nginx:7777 -> chatapp:3001

@MagicalPotato
Copy link

I also encountered this issue. After deploying directly with Docker Compose, I found that the requested address did not include the port. I understand that it should only work with a domain name. Is there a way to support IP + port?"
some config:
chatapp:
image: ghcr.io/muke1908/chat-e2ee:master
container_name: chat-app
restart: unless-stopped
env_file: .env
environment:
- MONGO_URI=mongodb://$MONGO_USERNAME:$MONGO_PASSWORD@db:$MONGO_PORT/admin?authSource=admin
ports:
- "8914:3001"
networks:
- app-network

MONGO_USERNAME=mongo
MONGO_PASSWORD=wwww123
MONGO_PORT=27017
MONGO_DB_NAME=test
CHAT_LINK_DOMAIN=http://123.45.678.9:8914
IMAGE_BB_API_KEY=123

@laishulu
Copy link
Author

To resolve the issue "Custom port does not work" in the repository muke1908/chat-e2ee, you can follow these steps:

  1. Check Environment Variable Configuration:
    Ensure that the CHAT_LINK_DOMAIN environment variable is set correctly, including the custom port. For example, it should be CHAT_LINK_DOMAIN=https://chat.example.com:7777.

  2. Update Backend Code:
    In the backend code, particularly in the file backend/api/chatLink/utils/link.ts, ensure that the CHAT_LINK_DOMAIN is used correctly to generate the chat link with the port.

    const generateLink = (): LinkType => {
      const hash = uuidv4();
    
      if (!CHAT_LINK_DOMAIN) {
        console.warn('CHAT_LINK_DOMAIN not found in env');
      }
    
      return {
        hash,
        link: `/chat/${hash}`,
        absoluteLink: CHAT_LINK_DOMAIN && `${CHAT_LINK_DOMAIN}/chat/${hash}`,
        expired: false,
        deleted: false,
        pin: generatePIN(hash, PIN_LENGTH),
        pinCreatedAt: new Date().getTime()
      };
    };
  3. Update Client Code:
    In the client-side code (client/src/pages/chatlink/index.tsx), ensure that the chat link generation uses the correct API endpoint which includes the custom port.

  4. Update Nginx Configuration:
    Ensure that your Nginx configuration correctly forwards requests from the custom port to your application server. For example:

    server {
      listen 7777;
      server_name chat.example.com;
    
      location / {
        proxy_pass http://chatapp:3001;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
      }
    }
  5. Test the Setup:
    After making these changes, restart your application server and Nginx, then test the setup by creating a chat link and ensuring it works with the custom port.

By following these steps, you should be able to resolve the issue with the custom port not working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants