There is an NGINX container, named gateway, on the server, which is connected to multiple NGINX containers via an external network.

This gateway NGIX’s responsibility is to proxy pass the subdomains to its corresponding container. The problem is, some subdomains are working properly but some of them are not.

Here is the default.conf

server {
    listen 80;
    server_name api.xxxxxx.com;
    location / {
        proxy_pass http://admin-panel;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

server {
    listen 80;
    server_name admin.xxxxxx.com;
    location / {
        proxy_pass http://admin-panel;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }
}

The admin.xxxxxx.com works well, and redirects to the admin-panel container while api.xxxxxx.com shows the connection refused error. The api.xxxxxx.com DNS is set and its ping returns the IP address of the server.

It is very surprising to me why the same proxy passes on different subdomains have different behaviors.