gpt4 book ai didi

nginx - 使用 nginx 将所有请求重定向到 api 服务器

转载 作者:行者123 更新时间:2023-12-02 01:54:36 26 4
gpt4 key购买 nike

我使用 Nginx 作为反向代理将 api 请求重定向到我的服务器。不幸的是它无法正常工作

我想要实现的是将 /api/v1/* 等所有请求代理到 http://my-api-server/api/v1/*

这是我写的规则

location /api/v1/ {
proxy_pass http://my-api-server/api/v1/
}

但它不起作用。有什么想法吗?

最佳答案

尝试

location /api/v1/ {
proxy_pass http://my-api-server
}

proxy_pass 指令中,如果您指定的 URI 为 /api/v1/ (在您的情况下),所有匹配的 URI 将被替换为确切指定的 >/api/v1/ 但不是 /api/v1/*

关于nginx - 使用 nginx 将所有请求重定向到 api 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29558204/

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