求助:Nginx+IIS负载均衡设置,后台主机名获取有问题

weir1999 2016-09-28 01:42:34
问题现象:
当我通过test.xxx.com访问,后台程序Request.Url获取到的主机名却是test.xx.com:82,多出了82端口号,这样导致后台程序再将Request.Url转给其它地方调用的时候出错了。

已经尝试将proxy_set_header Host设置为$http_host、$host:80、test.xxx.com等均无效,一样多出了82端口号。
请大神帮助看一下是Ngnix配置问题,还是IIS的web.config哪里需要调整呢?

IIS一样:IIS7.5+.net 4.0

nginx配置如下:
===========
worker_processes 1;
events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

upstream zttest{
server 10.xxx.xxx.249:82 weight=3 max_fails=1 fail_timeout=1800;
server 10.xxx.xxx.135:82 weight=1 max_fails=1 fail_timeout=1800;
}

server {
listen 80;
server_name localhost;
location / {
root html;
index default.aspx index.html index.htm;
proxy_pass http://zttest;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
...全文
991 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
  • 打赏
  • 举报
回复
proxy_pass http://zttest;后面改为: proxy_redirect off; proxy_set_header Host $host:82;
weir1999 2016-09-28
  • 打赏
  • 举报
回复
问题现象补充: 用ngnix反向代理做负载均衡,浏览器上输入显示的地址是“http://test.xxx.com/index.aspx”,后台程序request.url获得的却是“http://test.xxx.com:82/index.aspx”

8,327

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 IIS
社区管理员
  • IIS
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧