nginx反向代理,使用request.getServerName()获取域名错误

来源:互联网 发布:如何购买app软件 编辑:程序博客网 时间:2024/05/21 10:05
    # 反向代理服务,绑定域名www.abc.com          server {      listen       80;      server_name  www.abc.com;           charset utf-8;           # BBS使用Discuz!       # 因反向代理为了提高性能,一部分http头部信息不会转发给后台的服务器,      # 使用proxy_pass_header 和 proxy_set_header 把有需要的http头部信息转发给后台服务器      location ^~ /bbs/ {         root   html;         access_log off;         index index.php;         # 转发host的信息,如果不设置host,在后台使用request.getServerName()取到的域名不是www.abc.com,而是127.0.0.1         proxy_set_header Host $host;         # 因Discuz! 为了安全,需要获取客户端User-Agent来判断每次POST数据是否跟第一次请求来自同1个浏览器,         # 如果不转发User-Agent,Discuz! 提交数据就会报"您的请求来路不正确,无法提交"的错误         proxy_pass_header User-Agent;         proxy_pass http://127.0.0.1:8081;      }   


0 0
原创粉丝点击