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:
The domain resolution is working fine:
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:
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;
}
}
You have some nasty invalid syntax there for your proxy_pass
directive.
proxy_pass http://:maps:80;
isn't a valid proxy pass destination, http://:maps:80
wil fail because of that first colon after the //
.
Try proxy_pass http://maps:80;
but keep in mind the NGINX configuration pitfall of using a hostname to define a location/proxy pass destination/etc.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.