gpt4 book ai didi

Nginx proxy_pass所有url参数

转载 作者:行者123 更新时间:2023-12-02 00:52:32 29 4
gpt4 key购买 nike

我想代理这样的请求:http://myproxy.com/api/folder1/result1?test=1
, http://myproxy.com/api/folder3447/something?var=one

到等效的目的地:http://destination.com/folder1/result1?test=1http://destination.com/folder3447/something?var=one,实际上只有域发生变化,所有子文件夹和参数都被保留

配置中的位置如下所示:

location ~* ^/api/(.*) {
proxy_pass http://destination.com/$1$is_args$args;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
#proxy_set_header Host $http_host;
}

最佳答案

您应该能够稍微简化您的配置:

location /api/ {
// Note the slash at end, which with the above location block
// will replace "/api/" with "/". This will not work with regex
// locations
proxy_pass http://destination.com/;
proxy_redirect off;
proxy_http_version 1.1;
proxy_set_header Connection "";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

关于Nginx proxy_pass所有url参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38594788/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com