通过nginx代理后,获取请求URL(getRequestURL)的解决方法,host显示的是本地ip
程序员文章站
2022-06-11 13:29:30
...
location / {
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_pass http://127.0.0.1:8091;
}
// 请求url
String url = request.getRequestURL().toString();
配置之前后台获得的url:
http://127.0.0.1:8091/post/10148.html
配置之后
http://jiutianniao.net/post/10148.html