Score:0

www subdomain works but others don't

ph flag

I encountered a problem with nginx I do not understand.

I am able to correctly setup and call www.example.tech and example.tech.

However when adding another subdomain like survey.example.tld to the list the other two still work but survey.example.tld does not.

In chrome I get the following error message when trying to call http://survey.example.tech/:

This site can’t be reached Check if there is a typo in survey.example.tech. DNS_PROBE_FINISHED_NXDOMAIN

I am pretty sure there is no typo in it because I triple checked. Also, www.example.tech and example.tech still work.

I use nginx to forward requests to a gunicorn/flask app.

Therefore I put my config into /etc/nginx/sites-enabled

$ cat /etc/nginx/sites-enabled/survey.example.tech 

server {    
    server_name example.tech www.example.tech survey.example.tech;
    
    location /static {
        alias /opt/example.tech/my-domain-Survey-Website/static;
    }
    
    location / {
        proxy_pass http://localhost:8003;
        include /etc/nginx/proxy_params;
        proxy_redirect off;
        # Max file size allowed for upload by user. Here 1M = 1 Megabyte
        client_max_body_size 1M;
        
        # prevents warning messages when setting up let's encrypt
        proxy_headers_hash_max_size 512;
        proxy_headers_hash_bucket_size 128;
        
        # Enable Websocket by adding these two options
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
    }
}

and the corresponding service in /etc/systemd/system

$ cat /etc/systemd/system/gunicorn-my-domain-survey-flask.service 
[Unit]
Description = gunicorn for my-domain website
After = network.target

[Service]
Environment=LOG_PATH=/opt/example.tech/example.tech-Survey-Website/gunicorn-logs
User = ubuntu
Group = ubuntu
WorkingDirectory = /opt/example.tech/example.tech-Survey-Website
ExecStart = /opt/example.tech/venv/bin/gunicorn --bind 127.0.0.1:8003 -w 1 --log-level debug --access-logfile ${LOG_PATH}/access-logfile.log --error-logfile ${LOG_PATH}/error.log  --capture-output run_survey_website:app

[Install]
WantedBy = multi-user.target

When I run this everything works fine except for survey.example.tech.

What is happening here? Am I missunderstanding the setup of subdomains with nginx?

Richard Smith avatar
jp flag
The error is indicating a problem with your DNS and not your Nginx server.
Tom Tom avatar
ph flag
Oh man ‍♂️, right. Thanks
Score:0
us flag

The nginx configuration is fine.

You need to add a DNS record for survey.example.tech that points to the IP address of your server.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.