[英]Nginx: listen to 8080 for proxy_pass, but not 80
我似乎無法在端口80上使用此nginx配置。我嘗試使用nginx和gunicorn部署django應用程序。 我使用以下命令來運行gunicorn:
gunicorn myproj.wsgi:application --bind=127.0.0.1:8001 --workers=9
以下是nginx配置文件/etc/nginx/sites-enabled/myproj
:
server {
listen 8080;
location / {
proxy_pass http://127.0.0.1:8001;
}
location /static/ {
root /webapps/myproj/;
}
}
一切正常,除了我必須在http://localhost:8080/
輸入http://localhost:8080/
或http://xxx.xxx.xxx:8080/
才能使應用程序正確運行。 沒有端口號8080,將找不到該頁面。
但是,如果我更改listen 8080;
listen 80;
在配置文件( myproj
)中,然后在本地輸入http://localhost/
或在遠程輸入http://xxx.xxx.xxx/
,該頁面僅顯示來自nginx的歡迎消息。 Nginx似乎沒有將請求轉發到我的應用程序。 怎么了
您需要指定要綁定的域或IP。
listen XXX.XXX.XXX:80;
可能是因為其他服務器帶有listen 80;
存在。
您可以刪除其他服務器防護。 或改變listen 80;
listen 80 default_server;
。 或將server_name
指令用於基於名稱的過程。
閱讀有關nginx如何決定哪個服務器處理請求的內容: http : //nginx.org/en/docs/http/request_processing.html
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.