首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >多路径子域的Nginx反向代理配置

多路径子域的Nginx反向代理配置
EN

Stack Overflow用户
提问于 2015-09-17 21:47:31
回答 1查看 1.5K关注 0票数 1

我的Nginx反向代理配置遇到了这样的情况。我的发行版是Ubuntu 14.04

我有一个域,我们将其命名为foo.bar.net,我希望/grafana端点重定向到我的grafana服务器(localhost:3000),/sentry端点重定向到我的哨兵服务器(localhost:9000),最后,/private端点重定向到我的django服务器(localhost:8001)。在django和nginx之间的调谐中使用了gunicorn。

这是我尝试过的:

代码语言:javascript
运行
复制
server {
    # listen on port 80
    listen 80 default_server;

    # for requests to these domains
    server_name foo.bar.net;

    location /sentry {
        # keep logs in these files
        access_log /var/log/nginx/sentry.access.log;
        error_log /var/log/nginx/sentry.error.log;

        # You need this to allow users to upload large files
        # See http://wiki.nginx.org/HttpCoreModule#client_max_body_size
        # I'm not sure where it goes, so I put it in twice. It works.
        client_max_body_size 0;

        proxy_pass http://localhost:9000;
        proxy_redirect off;

        proxy_read_timeout 5m;
        allow   0.0.0.0;
        # make sure these HTTP headers are set properly
        proxy_set_header Host            $host;
        proxy_set_header X-Real-IP       $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /grafana {
        proxy_pass http://localhost:3000;
        proxy_redirect off;

        proxy_read_timeout 5m;
        allow   0.0.0.0;
        # make sure these HTTP headers are set properly
        proxy_set_header Host            $host;
        proxy_set_header X-Real-IP       $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    location /private {
        proxy_pass http://127.0.0.1:8001;
    }

    location /private/static/ {
        autoindex on;
        alias /home/user/folder/private/static/;
    }
}

服务器甚至不能正确启动,配置没有加载。

如果可能,我还希望/ path重定向到私有端点。

此外,我甚至不确定将此配置放在哪里(sites-available/??)

有人能帮我吗?

非常感谢,

EN

回答 1

Stack Overflow用户

发布于 2015-09-17 22:00:24

有一些缺少分号和其他语法错误。请查看nginx主错误日志了解详细信息,并逐一修复。

配置文件的位置取决于您的发行版。对于其中一些文件,它应该是sites available directory and symlink to them file in sites enabled directory以便快速启用和禁用站点,如果您没有sites available和sites enabled目录,则应将其放入发行版的conf.d目录中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32631952

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档