刚解决。没有配置规则,打开/etc/nginx/nginx.conf,http { server { listen 8080; # 监听8080端口 location / { proxy_pass http://$http_host$request_uri; # 将请求转发到目标服务器 proxy_set_header Host $http_host; # 设置请求头中的Host字段 proxy_set_header X-Real-IP $remote_addr; # 设置请求头中的X-Real-IP字段,记录客户端的真实IP地址 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 设置请求头中的X-Forwarded-For字段,记录经过的代理服务器IP地址 proxy_set_header X-Forwarded-Proto $scheme; # 设置请求头中的X-Forwarded-Proto字段,记录使用的协议(http或https) } } }