nginx 和反向代理的 http_sub_module/sub_filter 不起作用 [英] http_sub_module / sub_filter of nginx and reverse proxy not working
本文介绍了nginx 和反向代理的 http_sub_module/sub_filter 不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试反向代理我的网站并修改内容.为此,我使用 sub_filter 编译了 nginx.它现在接受 sub_filter 指令,但它以某种方式不起作用.
I am trying to reverse proxy my website and modify the content. To do so, I compiled nginx with sub_filter. It now accepts the sub_filter directive, but it does not work somehow.
server {
listen 8080;
server_name www.xxx.com;
access_log /var/log/nginx/www.goparts.access.log main;
error_log /var/log/nginx/www.goparts.error.log;
root /usr/share/nginx/html;
index index.html index.htm;
## send request back to apache1 ##
location / {
sub_filter <title> '<title>test</title>';
sub_filter_once on;
proxy_pass http://www.google.fr;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
请帮帮我
推荐答案
检查上游源是否开启 gzip,如果开启则需要
Check if the upstream source has gzip turned on, if so you need
proxy_set_header Accept-Encoding "";
所以整个事情就像
location / {
proxy_set_header Accept-Encoding "";
proxy_pass http://upstream.site/;
sub_filter_types text/css;
sub_filter_once off;
sub_filter .upstream.site special.our.domain;
}
检查这些链接
- https://www.ruby-forum.com/topic/178781
- https://forum.nginx.org/read.php?2,226323,226323
- http://www.serverphorums.com/read.php?5,542078
这篇关于nginx 和反向代理的 http_sub_module/sub_filter 不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文