【问题标题】:Nginx Proxy Pass not passing portNginx Proxy Pass 不通过端口
【发布时间】:2021-10-17 15:22:50
【问题描述】:

我目前在本地工作。

我有一个用于 nuxtwoo.example.com 的 NGINX 配置。 当我访问 nuxtwoo.example.com 时,我需要它来代理 localhost:3000,它工作正常,但我还需要它来传递端口:300。

location / {
    proxy_pass http://localhost:3000;
}

我需要什么,

http://nuxtwoo.example.com -> proxy_pass : localhost: 3000 -> 浏览器中的 URL,nuxtwoo.example.com:3000。

这也需要其他参数,例如 nuxtwoo.example.com/blog,应该去 proxy_pass localhost:3000/blog,浏览器 url 应该是 nuxtwoo.example.com:3000/blog。

似乎无法弄清楚这一点。

【问题讨论】:

    标签: nginx


    【解决方案1】:

    你需要使用上游

    upstream http_backend {
        server 127.0.0.1:8080;
    
        keepalive 16;
    }
    
    server {
        ...
    
        location /http/ {
            proxy_pass http://http_backend;
            proxy_http_version 1.1;
            proxy_set_header Connection "";
            ...
        }
    }
    

    【讨论】:

    • 对我来说不起作用。当我刷新 nuxtwoo.example.com 时,它不会在末尾添加端口。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-10-29
    • 2012-02-18
    • 2023-03-09
    • 2016-03-30
    • 1970-01-01
    相关资源
    最近更新 更多