2015-09-17 93 views
0

我在这里有我的Nginx反向代理配置的情况。我的发行版是Ubuntu 14.04具有多个路径的子域的Nginx反向代理配置

我有一个域,我们称之为foo.bar.net,并且我希望/ grafana端点重定向到我的grafana服务器(localhost:3000),/ sentry端点重定向到我的哨兵服务器(localhost:9000),最后,将/ private端点重定向到我的django服务器(localhost:8001)。我正在使用gunicorn进行django和nginx之间的tuneling。

这里是我的尝试:

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/; 
    } 
} 

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

我也想如果可能的话/ /路径重定向到专用端点。

此外,我甚至不知道在哪里把这个配置(站点可用/?)

谁能帮助我吗?

非常感谢,

回答

0

有一些缺少分号和其他语法错误。查看主要的nginx错误日志以获取详细信息并逐个修复它们。

何处放置该配置文件取决于您的分布。对于其中的一些应该是站点可用的目录和符号连接到启用站点的目录中的该文件以快速启用和禁用站点,如果您没有站点可用和站点启用目录,则应将其放入conf.d中目录在您的发行版中。

+0

谢谢,我改变了配置,所以没有语法错误了。但仍然没有运气。我的发行版是Ubuntu 14.04。 – justinlevol