通过nginx代理后getRequestURL取不到当前访问的URL
通过nginx代理后getRequestURL取得的值是http://tomcat,取不到访问的URL,不知道哪个大哥碰到过类似问题没有?
我的nginx配置
upstream tomcat {
server 127.0.0.1:8080;
}
server {
listen 80;
server_name www.mydomain.com;
#charset koi8-r;
#access_log logs/host.access.log main;
location ~ ^/(css|images|js)/ {
root /cygdrive/h/apache-tomcat-6.0.18/webapps/shop;
}
location ~ ^/(user|comment)/.+$ {
index index.html index.htm;
rewrite "^/(.+)$" /shop/$1 last;
}
location ~ ^/(shop)/.*$ {
proxy_pass http://tomcat;
}
error_page 404 /404.html;
location = /404.html {
root /cygdrive/c/nginx/html;
}
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /cygdrive/c/nginx/html;
}
}
[解决办法]
具体我没有测试过
是不是需要设置
proxy_redirect off
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
再有问题联系我吧:1124151686