请问大家怎样配置才能让服务端获得正确的客户端IP,当前获得的是docker内的IP地址。下面是我当前的配置:
-
按照官方文档部署docker版seafile;
-
安装nginx服务器:
#yum install nginx
- 创建配置文件反带到docker版seafile(seafile.example.com是服务器域名):
#vi /etc/nginx/conf.d/seafile.example.com.conf
server {
listen 80;
server_name seafile.example.com;
rewrite ^ https://$http_host$request_uri?permanent;
server_tokens off;
}
server {
listen 443 ssl;
server_name seafile.example.com;
ssl_certificate /root/.acme.sh/seafile.example.com/fullchain.cer;
ssl_certificate_key /root/.acme.sh/seafile.example.com/seafile.example.com.key;
add_header Strict-Transport-Security "max-age=31536000; includeSubDomains";
server_tokens off;
location / {
proxy_pass http://127.0.0.1:8000;
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-Host $server_name;
proxy_set_header X-Forwarded-Proto https;
client_max_body_size 0;
}
}