2015-09-17 90 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