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

请教一下使用Nginx反代如何获取真实IP #32

Closed
JXY415 opened this issue Jan 11, 2023 · 6 comments
Closed

请教一下使用Nginx反代如何获取真实IP #32

JXY415 opened this issue Jan 11, 2023 · 6 comments
Labels
enhancement New feature or request

Comments

@JXY415
Copy link

JXY415 commented Jan 11, 2023

使用Docker安装的 并且将端口改为8800,具体部署命令如下:
docker run -d --restart always
--name lookingglass
-e HTTP_PORT=8800
-p 8800:8800
wikihostinc/looking-glass-server

在使用Nginx将端口反代到域名时发现反代后无法正确识别IP地址,IP地址显示为172.17.0.1,
image
Nginx配置如下:
#PROXY-START/

location /
{
proxy_pass http://127.0.0.1:8800;
proxy_set_header Host $http_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;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
proxy_http_version 1.1;
}
#PROXY-END/

想请教下如何配置能获取到访问的真实IP呢?

@samlm0
Copy link
Contributor

samlm0 commented Jan 11, 2023

未有相关参数, 后续添加

@samlm0 samlm0 added the enhancement New feature or request label Jan 11, 2023
@Ir1Ka
Copy link

Ir1Ka commented Jan 16, 2023

未有相关参数, 后续添加

还有测试下载的文件希望也能识别一下 hostname,而不是默认用ip地址。

@samlm0
Copy link
Contributor

samlm0 commented Jan 17, 2023

未有相关参数, 后续添加

还有测试下载的文件希望也能识别一下 hostname,而不是默认用ip地址。

已在 #33 修复

@wuwentao
Copy link

同样使用nginx反代到https协议下面,指定location /looking_glass
貌似页面显示也不正常了,相关的js/css都是直接相对根目录的/assets

@samlm0
Copy link
Contributor

samlm0 commented Mar 30, 2023

同样使用nginx反代到https协议下面,指定location /looking_glass 貌似页面显示也不正常了,相关的js/css都是直接相对根目录的/assets

#38 修复了.

@samlm0
Copy link
Contributor

samlm0 commented Mar 30, 2023

反代时添加以下参数到相关 vhost 中即可

proxy_protocol on;

创建容器的时候带上环境变量

BEHIND_PROXY=true

已在 #40 中实现

@samlm0 samlm0 closed this as completed Mar 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants