Apache2配置反向代理ProxyPass时设置header
如果不需要设置附加的header,通常:
折叠复制代码
- ProxyPass /static/js http://127.0.0.1/
如果在反向代理时,需要设置附加的header,则可放在一个location中
折叠复制代码
- <Location/static/js/>
- RequestHeader set Host 'js.sohu.com'
- ProxyPass http://127.0.0.1/
- </Location>
注意:此时的PrxoyPass不能有2个参数,就只需要一个反向代理后的url参数
其实,和Nginx的就很类似了,以下为Nginx的配置
折叠复制代码
- location ^~ /static/js/
- {
- proxy_set_header Host js.sohu.com;
- proxy_pass http://127.0.0.1/;
- }