I'm trying to setup a docker swarm with multiple networks, so I can run a set of services (in different versions) on different networks on the swarm. I also want to access these services outside of the swarm, but do not want to fight for ports each time I startup a new service
To handle this I'm trying to setup a proxy using nginx, so I can point http://service-v1.swarm-master/config/ to my etcd-viewer running at http://etcd-viewer.rest-test:8080 on the rest-test overlay network; all on the swarm. This is giving me some headache as of now!
When going to http:// service-v1.swarm-master/config/ I'm met with a 404 page:
HTTP ERROR 404
Problem accessing /config/. Reason:
Not Found
Powered by Jetty://
From inside my nginx container I have made sure that I can in fact reach the services that I'm trying to access by doing a ping -c1 etcd-viewer
and ping -c1 etcd-viewer.rest-test
. There's access to both from inside the running nginx container.
So why does my nginx.conf not seem to work? It is mounted at /etc/nginx/conf.d/
.
resolver 127.0.0.11;
upstream config {
server etcd-viewer.rest-test:8080;
}
log_format compression '$remote_addr - $remote_user [$time_local] '
'"$request" $status $request_body ($body_bytes_sent) '
'"$http_referer" "$http_user_agent" "$gzip_ratio"';
server {
listen 80;
#server_name docker.cdrator.com;
access_log /var/log/nginx/access.log compression;
# disable any limits to avoid HTTP 413 for large image uploads
client_max_body_size 0;
# required to avoid HTTP 411: see Issue #1486 (https://github.com/docker/docker/issues/1486)
chunked_transfer_encoding on;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /config/ {
proxy_pass http://config;
proxy_set_header Host $http_host; # required for docker client's sake
proxy_set_header X-Real-IP $remote_addr; # pass on real client's IP
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 900;
}
location /basic_status {
stub_status;
}
}