NGINX Configuration Issue: One Domain Works, Another Doesn't

Question:

I’m facing an issue with my NGINX configuration where one of my domains works correctly, but the other doesn’t. I have two domains (domain1.site and domain2.site) with their respective configurations in NGINX.

Here’s the NGINX configuration for domain1.site:

server {
    listen 80;
    server_name domain1.site www.domain1.site;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name domain1.site www.domain1.site;

    ssl_certificate /etc/letsencrypt/live/domain1.site/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/domain1.site/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:8222;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

And here’s the NGINX configuration for domain2.site:

server {
    listen 80;
    server_name domain2.site www.domain2.site;
    return 301 https://$host$request_uri;
}

server {
    listen 443 ssl;
    server_name domain2.site www.domain2.site;

    ssl_certificate /etc/letsencrypt/live/domain2.site/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/domain2.site/privkey.pem;

    location / {
        proxy_pass http://127.0.0.1:3222;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }
}

The issue is that while domain1.site works perfectly, domain2.site doesn’t seem to respond (gives Welcome to Nginx! instead of page).

The websites are powered by Python Flask. I launch them through Gunicorn. Both Flask and Gunicorn are configured with the same ports as specified in the NGINX configurations.

I’ve tried disabling SSL for domain2.site to see if that makes a difference, but the issue persists. I’ve verified that DNS records are correctly pointing to the server’s IP address.

Could you please help me troubleshoot this issue? Are there any specific steps I can take to identify the problem and resolve it? Thank you in advance for your assistance!

Asked By: overklassniy

||

Answers:

Solved the problem by unlinking the default configuration in /etc/nginx/sites-enabled/default.

Answered By: overklassniy
Categories: questions Tags: , , , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.