Today I recur to your expertise I’m a novice with some trouble that is killing my head.
I'm working with a TileServerGL server providing OpenStreet.org map in a docker container within a swarm. This server is working fine, if port 80 is exposed and redirected to, lets say 8080, I can reach its content at [IP Docker Swarm]:8080.
Now I need to add a reverse proxy in front of this container to add some security (but not yet, first I need to make the reverse proxy to work), so I add a Nginx container to the docker-compose.yml file and I’m trying to configure correctly the simplier version of a nginx reverse proxy, without much success.
I have tried:
- Running it locally with docker-compose up –build
- Running inside a swarm in my local machine with: docker stack deploy -c docker-compose.yml lab
- Running inside Vbox machines with: docker stack deploy -c docker-compose.yml lab
The domain resolution is working fine:
- my swam IP is: 192.168.1.105
- at etc/hosts I have: 192.168.1.105 app.io
When I open http://app.io at the browser I get the default Nginx welcome page. So far so good. But when I hit http://maps.app.io I still getting the same default welcome page.
The Nginx server log:
10.255.0.2 - - [01/Dec/2018:00:55:59 +0000] "GET / HTTP/1.1" 304 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36" "-"
I would not appeal to your help with out before reading every post, article , tutorial that I’ve found on the internet. As I see it the “nginx.conf” file is correct, but the reality show me that I’m undoubtedly wrong and blind to my mistake. I’ll really appreciate your help.
I’m running:
- linux Mint 19 Tara
- Docker version: Docker version 18.09.0, build 4d60db4
- Docker machine version: docker-machine version 0.16.0, build 702c267f
The docker-compose.yml file:
version: "3.5"
networks:
nginx-net:
driver: overlay
services:
maps:
image: xxxx/xxxx:mapstiles
volumes:
- ./server_mapstiles/app/data:/data
networks:
- nginx-net
deploy:
restart_policy:
condition: on-failure
replicas: 1
nginx:
image: nginx:1.15.7
container_name: nginx
ports:
- "80:80"
networks:
- nginx-net
volumes:
- ./server_nginx/nginx.conf:/etc/nginx/proxy.conf:ro
deploy:
restart_policy:
condition: on-failure
replicas: 1
depends_on:
- maps
The nginx conf file is:
server {
listen 80;
server_name maps.app.io;
location / {
proxy_pass http://:maps:80;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For
$proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $server_name;
resolver 127.0.0.11;
}
}