Two identical subdomains with similar nginx proxy but only the other one works

Two subdomains that uses the identical NGINX config. However both config’s server_name are set to their respective subdomain. Here comes the problem they both listen to the same port but only the other one works. If I remove the working one still it doesn’t work. In this scenario the working subdomain is “auth” and the non-working subdomain is “android”.

Do they work when the records are not proxied by Cloudflare?

No, Unfortunately they both do not.

“refused to connect”

If they don’t work while unproxied you likely have a configuration issue with your nginx config. That would need to be remediated before Cloudflare can proxy traffic to the site(s).

I use cloudflare-ips for X-Real-IP;

I use full strict SSL;

Both uses the same config but both’s server_name are set to their respective sub domains.

server {
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name  android.domain.x;
    root my-path;

    add_header X-Frame-Options "SAMEORIGIN";
    add_header X-XSS-Protection "1; mode=block";
    add_header X-Content-Type-Options "nosniff";

    charset utf-8;

    location / {
        proxy_pass http://localhost:54160;
        add_header X-Forwarded-Proto https;
        add_header X-Forwarded-Port 443;
        fastcgi_param  HTTPS "on";
        fastcgi_param  HTTP_X_FORWARDED_PROTO "https";
        proxy_http_version 1.1;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        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-Proto $scheme;
    }
}

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.