【发布时间】:2014-06-03 11:48:36
【问题描述】:
我试图让我的 Django 应用程序在 VPS 上运行,我做了所有事情 according to this tutorial,但我收到了 502 错误。
我假设 nginx 正在监听 80 端口(对吗?),因为sudo netstat -nlp | grep 80 抛出:
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 892/nginx
tcp6 0 0 :::80 :::* LISTEN 892/nginx
unix 2 [ ACC ] STREAM LISTENING 8942 805/acpid /var/run/acpid.socket
但是当我输入sudo nginx 时,似乎Nginx 没有监听端口80 ...:
`nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] bind() to 0.0.0.0:80 failed (98: Address already in use)
nginx: [emerg] bind() to [::]:80 failed (98: Address already in use)
nginx: [emerg] still could not bind()`
我的 Nginx 配置:
server {
server_name 95.85.34.87;
access_log off;
location /static/ {
alias /opt/myenv/static/;
}
location / {
proxy_pass http://127.0.0.1:8001;
proxy_set_header X-Forwarded-Host $server_name;
proxy_set_header X-Real-IP $remote_addr;
add_header P3P 'CP="ALL DSP COR PSAa PSDa OUR NOR ONL UNI COM NAV"';
}
}
谁能帮帮我?
【问题讨论】:
-
您在 80 端口上运行其他服务吗?你是如何运行 gunicorn 的?
-
我认为我没有在端口 80 上运行任何其他服务,因为我已经粘贴了
sudo netstat -nlp | grep 80抛出的全部信息(我认为它过滤了哪些服务正在使用端口 80)。我对教程做了所有的事情,所以我像文章所说的那样使用 Gunicorn:gunicorn_django --bind 95.85.34.87:8001。顺便说一句,访问95.85.34.87:8001 工作正常,但我认为这不是它应该工作的方式。 -
感谢您的回答,但不幸的是我遇到了同样的错误 - nginx 侦听端口 80,但“地址已在使用中”..