【发布时间】:2015-10-31 19:29:44
【问题描述】:
我正在尝试反向代理我的网站并修改内容。 为此,我使用 sub_filter 编译了 nginx。 它现在接受 sub_filter 指令,但它不能以某种方式工作。
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;
}
}
请帮帮我
【问题讨论】:
-
为什么要修改 Nginx 配置中的内容?你想在转发代理模式下使用 Nginx 吗?
-
因为我打算以这种方式向网站添加页眉和页脚。我想在反向代理模式下使用它。
-
我什至尝试过 Httpsubs 和 subs_filter,它也不起作用。有人有想法吗?
-
基于 proxy_pass google.fr 看来您尝试构建正向代理而不是反向代理?
-
是的,谷歌只是为了尝试一下。我现在尝试反向代理列出默认页面的 apache 目录并且它可以工作。我在某处读到 httpsubs 与 gzip 服务的页面有问题,所以我添加了 proxy_set_header Accept-Encoding "";尝试从服务器禁用 gzip 但没办法:/
标签: nginx proxy reverse inject