【问题标题】:nginx point API URLs to live websitenginx 点 API URL 到实时网站
【发布时间】:2017-08-01 22:38:59
【问题描述】:

nginx 指向实时网站的 API URL

位置 = http://localhost:5100/services/v1/ { proxy_pass https://test.com/services/v1/; }

【问题讨论】:

    标签: nginx


    【解决方案1】:

    确保您仅在服务器块中侦听端口 5100,以确保重定向仅在 5100 上发生。

    server {
        listen 5100;
        server_name localhost;
    
        location /services/v1/ {
            proxy_pass https://test.com/services/v1/;
        }
    }
    

    【讨论】:

    • nginx 返回 204 无内容
    【解决方案2】:

    假设您的意图是将 /services/v1/* api 请求转发到 test.com, 位置/服务/v1/ { proxy_pass https://test.com/services/v1/; }

    【讨论】:

    • 是的,但仅适用于端口 5100
    • 是的。想强调不要在位置块中使用 =。这就是精确的 URI 匹配。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2013-11-30
    • 2013-12-19
    • 1970-01-01
    • 1970-01-01
    • 2021-04-09
    • 2021-10-13
    • 2015-03-24
    相关资源
    最近更新 更多