The original post: /r/nginx by /u/_Arelian on 2024-07-29 18:43:18.

I have a docker container running nginx as a reverse proxy, in my nginx.conf file I have the following configuration

upstream portainer-web {
    server portainer:9000;

}

server {

    listen 80;
    listen [::]:80;

    server_name portainer.192.168.2.20 portainer.localhost portainer.my-domain.com;

    location / {
        proxy_pass http://portainer-web;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
        proxy_ssl_server_name on;
    }
}

upstream pihole-web {
    server pihole:80;
}

server {

    listen 80;
    listen [::]:80;

    server_name pihole.192.168.2.20 pihole.localhost pihole.my-domain.com;
    location / {
        proxy_pass http://pihole-web;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $host;
        proxy_redirect off;
        proxy_ssl_server_name on;
    }
}

when I access my my-domain.com, portainer shows up but that does not make sense since there is no configuration for that service on that port.

I know I can just add another configuration for port 80 to display an error, however, I do not understand why it serves portainer on that port, any ideas why?