
Encontrei um problema com o nginx que não entendo.
Consigo configurar e ligar corretamente www.example.tech
e example.tech
.
No entanto, ao adicionar outro subdomínio survey.example.tld
à lista, os outros dois ainda funcionam, mas survey.example.tld
não.
No Chrome recebo a seguinte mensagem de erro ao tentar ligar http://survey.example.tech/
:
Este site não pode ser acessado Verifique se há um erro de digitação em survey.example.tech. DNS_PROBE_FINISHED_NXDOMAIN
Tenho certeza de que não há nenhum erro de digitação porque verifiquei três vezes. Além disso, www.example.tech
e example.tech
ainda funciona.
Eu uso o nginx para encaminhar solicitações para um aplicativo gunicorn/flask.
Portanto coloquei minha configuração em/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";
}
}
e o serviço correspondente em/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
Quando executo isso, tudo funciona bem, exceto survey.example.tech
.
O que esta acontecendo aqui? Estou entendendo mal a configuração de subdomínios com o nginx?
Responder1
A configuração do nginx está correta.
Você precisa adicionar um registro DNS survey.example.tech
que aponte para o endereço IP do seu servidor.