我在nginx(http://52.xx.xx.xx/)访问我的IP时遇到502网关错误,日志只是这样说:
2015/09/18 13:03:37 [错误] 32636#0:*1 connect()失败(111:连接被拒绝)连接到上游,客户端:xx.xx.xx.xx,服务器:xx.xx. xx.xx,请求:"GET/HTTP/1.1",上游:"uwsgi://127.0.0.1:8000",主机:"xx.xx.xx.xx"
我的nginx.conf文件
# the upstream component nginx needs to connect to
upstream django {
# server unix:///path/to/your/mysite/mysite.sock; # for a file socket
server 127.0.0.1:8000; # for a web port socket (we'll use this first)
}
# configuration of the server
server {
# the port your site will be served on
listen 80;
# the domain name it will serve for
server_name xx.xx.xx.xx; # substitute your machine's IP address or FQDN
charset utf-8;
access_log /home/ubuntu/test_django/nginx_access.log;
error_log /home/ubuntu/test_django/nginx_error.log;
# max upload size
client_max_body_size 75M; # adjust to taste
# Django media
location /media {
alias /home/ubuntu/test_django/static/media/; # your Django project's media files - amend as required
}
location /static {
alias /home/ubuntu/test_django/static/; # your Django project's static files - amend as required
}
# Finally, send all non-media requests to the Django server.
location / {
uwsgi_pass django;
include /home/ubuntu/test_django/uwsgi_params; # the uwsgi_params file you installed
}
}
Run Code Online (Sandbox Code Playgroud)
nginx.conf文件有什么问题.....如果我使用默认conf那么它正在工作.
我通过将 uwsgi.ini 中的套接字配置从socket = 127.0.0.1:3031, 更改为socket = :3031. 当我在一个 Docker 容器中运行 nginx 而在另一个容器中运行 uWSGI 时,我遇到了这个问题。如果您使用命令行启动 uWSGI,则执行uwsgi --socket :3031.
希望这有助于在使用 Docker 部署 Django 应用程序期间遇到同样问题的人。
小智 0
更改此地址:
include /home/ubuntu/test_django/uwsgi_params;
Run Code Online (Sandbox Code Playgroud)
到
include /etc/nginx/uwsgi_params;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
12675 次 |
| 最近记录: |