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

Dockerfile: Listen to any addresses instead of localhost, fixes #4682 #4689

Merged
merged 3 commits into from
May 22, 2024

Conversation

ReeseWang
Copy link
Contributor

No description provided.

Copy link

vercel bot commented May 14, 2024

@ReeseWang is attempting to deploy a commit to the NextChat Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

Your build has completed!

Preview deployment

@ReeseWang
Copy link
Contributor Author

ReeseWang commented May 15, 2024

HOSTNAME=127.0.0.1是在 #1738 引入的,目的是解决proxychains代理本地地址的问题。首先我觉得proxychains不会使用HOSTNAME这个环境变量,其次HOSTNAME这个变量会被nodejs拿来作为监听地址,而监听127.0.0.1会拒绝一切从外部来的连接。

编辑:我大概明白为什么有HOSTNAME=127.0.0.1了,见#1556。nodejs想访问本机的时候用的是HOSTNAME环境变量作为域名,被解析到了192.168.0.0/16,10.0.0.0/8,172.16.0.0/12和公网这样的地址上,然后proxychains会试图用代理服务器访问这些地址。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


HOSTNAME=127.0.0.1 was introduced in #1738 to solve the problem of proxychains proxying local addresses. First of all, I think proxychains will not use the HOSTNAME environment variable. Secondly, the HOSTNAME variable will be used by nodejs as the listening address, and listening on 127.0.0.1 will reject all connections from the outside.

@ReeseWang ReeseWang changed the title Dockerfile: Listen to any addresses instead of localhost, fixes #4682 Dockerfile: Don't set HOSTNAME in CMD, fixes #4682 May 15, 2024
@ReeseWang
Copy link
Contributor Author

新观察到的行为:在HOSTNAME/etc/hostname保持一致的情况下,如果用proxychains启动nodejs,nodejs会监听127.0.0.1:3000,无法从外部访问。所以我前一个commit把HOSTNAME设置为0.0.0.0是正确的。

proxychains太不科学了,彻底解决问题的方法是把它扔掉。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Newly observed behavior: When HOSTNAME and /etc/hostname are consistent, if nodejs is started with proxychains, nodejs will listen on 127.0.0.1:3000 and cannot be accessed from the outside. So my previous commit set HOSTNAME to 0.0.0.0 which is correct.

Proxychains is so unscientific that the only way to completely solve the problem is to throw it away.

@ReeseWang ReeseWang changed the title Dockerfile: Don't set HOSTNAME in CMD, fixes #4682 Dockerfile: Listen to any addresses instead of localhost, fixes #4682 May 15, 2024
@fred-bf
Copy link
Contributor

fred-bf commented May 15, 2024

Hi @ReeseWang would you mind check whether the latest commit works as expected, I just customized the nodejs listen address with --host flag

@ReeseWang
Copy link
Contributor Author

@fred-bf Nope, still listening on 127.0.0.1.

@fred-bf fred-bf merged commit 3866448 into ChatGPTNextWeb:main May 22, 2024
1 of 2 checks passed
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

Successfully merging this pull request may close these issues.

4 participants