当我想在Nginx反向代理中替换字符串时,我使用
sub_filter 'https://upstream.com' 'http://www.localhost:8080';
sub_filter_once off;
字符串
但它不工作(因为它的gzipped),所以我添加
proxy_set_header Accept-Encoding "";
型
但随后请求超时(网关超时)。我想知道这是怎么可能的,我试图做一个GET到upstream.com与 Postman 与Accept-Encoding
头设置为空,它工作正常,所以这是一个问题,对我来说。
我的配置看起来像:
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 8080;
server_name localhost;
location / {
proxy_pass https://www.upstream.com;
proxy_hide_header 'x-frame-options';
proxy_cookie_domain ~^(.*)$ "http://www.localhost:8080";
proxy_set_header X-Real-IP $remote_addr;
proxy_cookie_path / "/; secure; HttpOnly; SameSite=none";
sub_filter 'https://www.upstream.com' 'http://www.localhost:8080';
sub_filter_once off;
sub_filter_types text/html;
proxy_set_header Accept-Encoding "";
}
}
}
型
PS:upstream.com只是一个例子,我使用另一个网址。
1条答案
按热度按时间njthzxwz1#
尝试使用gunzip模块。更多信息here .
字符串