我有一个反向代理,根据请求的Host
派生两个不同的站点。简单吧?第一个站点使用HTTP,第二个站点使用HTTPS。这是我的服务器块:
gzip_proxied off;
server {
listen 80 default_server;
server_name test.example.com;
error_log /var/log/nginx/error.log debug;
location / {
# needed so subfilter can work (prevents upstream server gzipping content)
proxy_set_header Accept-Encoding "";
proxy_redirect off;
proxy_pass http://test.site.biz/site;
sub_filter 'test.site.biz/site' 'test.example.com:8001';
sub_filter_once off;
sub_filter_types *;
}
}
server {
listen 80;
server_name app.test.example.com;
error_log /var/log/nginx/error.log debug;
location / {
proxy_set_header Host my-site.com;
proxy_ssl_server_name on;
proxy_redirect off;
proxy_pass https://my-site.com;
}
}
第二个站点(app.test.example.com)正常运行。第一个站点就是问题所在。 请求通过得很好,但是未应用子过滤器-如果我对test.site.biz/site的curl输出进行grep复制,则会在HTML中看到它,并且它没有被更改。
这里的常见问题是响应被压缩,但是如您所见,我通过清除Accept-Encoding标头抑制了这一点。有什么主意我想念的吗?
ps。子过滤器中的:8001
是经过精心设计的,它是一个测试配置,位于容器中,监听8001,将请求转发到nginx的端口80。
ps2。我已经检查过,并且我的nginx
版本 确实已经编译了subfilter
模块。