1、apache:在<VirtualHost/>标签中的最后添加ProxyPreserveHost on
<VirtualHost *:80> RewriteEngine on ProxyPass /TLimages/ ! ProxyPass /imagelist/ ! ProxyPass /xiazai/ ! ProxyPass /ad/ ! ProxyPass / balancer://proxy/ ProxyPassReverse / balancer://proxy/ ProxyPreserveHost on </VirtualHost>
2、nginx:在location {…}中添加proxy_set_header Host $host
location ^~/proxy_path/ { root "/www/html"; index index.html; proxy_pass http://192.168.100.101/; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; }
3、iis:设置preserveHostHeader:true
%windir%\system32\inetsrv\appcm d.exe set config -section:system.webServer/proxy -preserveHostHeader:true /commit:apphost
iis反向代理指定Host配置:
设置preserveHostHeader:true之后再添加URL重写服务器变量。
1.打开URL重写
2.点击查看服务器变量
3.点击添加
4.添加HTTP_HOST
5.web.config反向代理配置
设置preserveHostHeader:true之后再添加URL重写服务器变量。
1.打开URL重写
2.点击查看服务器变量
3.点击添加
4.添加HTTP_HOST
5.web.config反向代理配置
<rule name="Proxy" stopProcessing="true"> <match url="(.*)" /> <serverVariables> <set name="HTTP_HOST" value="www.yqll.com" /> </serverVariables> <action type="Rewrite" url="http://192.168.100.101/{R:1}" /> </rule>