我在我的Mac上安装了Django,uWSGI和Docker,然后运行NGINX docker镜像以共享我的项目目录。
docker run -v ~/Projects:/Projects -v /Projects/My-Project/My-Project_nginx.conf:/etc/nginx/conf.d/My-Project_nginx.conf:ro -p 80:80 -d nginx
启动uWSGI并测试后,NGINX收到错误"111: Connection refused"
:
2017/08/09 05:38:00 [error] 18#18: *11 connect() to unix:///Projects/My-Project/My-Project.sock failed (111: Connection refused) while connecting to upstream, client: 172.17.0.1, server: 172.16.10.30, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:///Projects/My-Project/My-Project.sock:", host: "172.16.10.30", referrer: "http://172.16.10.30/"
172.17.0.1 - - [09/Aug/2017:05:38:00 +0000] "GET /favicon.ico HTTP/1.1" 502 575 "http://172.16.10.30/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36" "-"
问题出现在我的Mac上,因为我测试了它们在Ubuntu上运行。共享.sock文件很好。
有人说“Socket sharing is possible, but not supported on OSX”,这是真的吗?为什么?我能以某种方式修复它吗?
或者,对我的情况有更好的方法吗?我知道docker-compose
就是为此而生,但我希望通过自己更灵活的方式进行组装,减少对互联网的依赖。
server {
listen 80;
server_name 172.16.10.30;
charset utf-8;
client_max_body_size 75M;
location /media {
alias /Projects/My-Project/media;
}
location /static {
alias /Projects/My-Project/static;
}
location / {
uwsgi_pass unix:///Projects/My-Project/My-Project.sock;
include /etc/nginx/uwsgi_params;
}
}
[uwsgi]
project = My-Project
chdir = /Projects/%(project)
master = true
processes = 2
socket = %(project).sock
wsgi-file = %(project)/wsgi.py
chmod-socket = 666
vacuum = true
py-autoreload = 1