我在default.conf
location /api-gateway/ {
proxy_http_version 1.1;
proxy_connect_timeout 75s;
proxy_read_timeout 100s;
client_max_body_size 100m;
proxy_set_header Host test.domain.com;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_buffering off;
proxy_buffers 16 8k;
proxy_buffer_size 4k;
proxy_max_temp_file_size 0;
rewrite ^/api-gateway/(.*)$ $1 break;
proxy_pass http://ingress-srv; # ingress-srv is an upstream
}
以下是我的NGINX服务器的请求示例:http://demo.domain.com/api-gateway/service/v1/metrics
我需要做以下
/api-gateway/
,然后ingress-srv
上游而不是
更改网址(无重定向)demo.domain.com
更改为test.domain.com
,我相信我已经正确完成了我无法让它发挥作用..
答案 0 :(得分:3)
而不是
proxy_pass http://ingress-srv; # ingress-srv is an upstream
尝试做(注意斜杠):
proxy_pass http://ingress-srv/; # ingress-srv is an upstream
您可以取出rewrite
指令。
正如奥斯卡·王尔德所说的那样,我整个上午都在研究nginx.conf,然后拿出一个逗号。下午我又回来了。"