【问题标题】:How do I set up nginx to serve data from a port?如何设置 nginx 以从端口提供数据?
【发布时间】:2012-05-18 06:44:42
【问题描述】:

我让 nginx 在端口 80 上提供一个页面。

server {
listen   80;
server_name .example.com;
root       /var/www/docs;
index      index.html;
}

我还有一个服务在端口 9000 上运行服务器。如何在 nginx 中设置一个虚拟目录(例如 /service)来服务端口 9000 上的任何内容?我无法打开其他端口,所以我想通过端口 80 上的某种虚拟目录来提供此服务。

【问题讨论】:

    标签: nginx virtual-directory


    【解决方案1】:

    that 开始(但您肯定需要更多指令才能使您的服务器正常响应此子目录):

    location /something {
        proxy_pass http://localhost:9000/;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
    }
    

    【讨论】:

    猜你喜欢
    • 2020-12-27
    • 1970-01-01
    • 2018-10-07
    • 1970-01-01
    • 1970-01-01
    • 2020-08-15
    • 2017-07-31
    • 1970-01-01
    • 2012-06-17
    相关资源
    最近更新 更多