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?