今天遇到一个奇怪的问题,把原业的asp.net的项目用nginx代理后,放在后面就无法登录了,不经过Nginx代理是正常的。经过日志和错误提示,发现是程序在登录时要解析客户端的主机名,那肯定是代理的配置没有转发主机名。后仔细对比后,发现我的配置少了一行:
proxy_set_header REMOTE-HOST $remote_addr;
完整配置如下:
location / { proxy_pass http://127.0.0.1:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection keep-alive; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; proxy_set_header X-Real-IP $remote_addr; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto $scheme; }