Reputation: 12833
I've set up uWSGI and NGINX locally and my configurations have no issue serving web requests. However, when I containerize uWSGI and NGINX (in separate Docker containers) I can't seem to make a connection. My NGINX server configuration looks like this:
server {
listen 80;
server_name localhost;
location / {
include uwsgi_params;
uwsgi_pass uwsgi.app:9090;
}
}
My uWSGI ini file looks like this:
[uwsgi]
socket = localhost:9090
module = uwsgi:app
processes = 4
threads = 2
master = true
buffer-size = 32768
stats = localhost:9191
die-on-term = true
vaccuum = true
I run the containers both in the same user-generated bridge network using the following for uWSGI docker run -p 9090:9090 --network main --name uwsgi.app -d uwsgirepo
; and docker run -p 80:80 --network main --link uwsgi.app --name nginx.app -d nginxrepo
for NGINX.
When I try to make a request on my local machine I get the following error message from the NGINX logs: '[error] 7#7: *1 connect() failed (111: Connection refused) while connecting to upstream, client: 172.18.0.1, server: localhost, request: "GET /endpoint HTTP/1.1", upstream: "uwsgi://172.18.0.2:9090", host: "127.0.0.1"'
It doesn't look like it's ever connecting to uWSGI. Not sure where to go from here. Any thoughts?
Upvotes: 0
Views: 2228
Reputation: 6534
Configure uwsgi to listen on 0.0.0.0
instead of localhost. That'll make it listen on all the containers interfaces. You are getting a connection refused because it's only listening on the uwsgi container's localhost, and not the container's eth0.
Upvotes: 5