El subdominio www funciona pero otros no.

El subdominio www funciona pero otros no.

Encontré un problema con nginx que no entiendo.

Puedo configurar y llamar correctamente www.example.techy example.tech.

Sin embargo, al agregar otro subdominio similar survey.example.tlda la lista, los otros dos aún funcionan, pero survey.example.tldno.

En Chrome recibo el siguiente mensaje de error al intentar llamar http://survey.example.tech/:

No se puede acceder a este sitio. Compruebe si hay un error tipográfico en Survey.example.tech. DNS_PROBE_FINISHED_NXDOMAIN

Estoy bastante seguro de que no hay ningún error tipográfico porque lo verifiqué tres veces. Además, www.example.techy example.techtodavía funciona.

Utilizo nginx para reenviar solicitudes a una aplicación gunicorn/flask.

Por lo tanto puse mi configuración en/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";
    }
}

y el servicio correspondiente en/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

Cuando ejecuto esto, todo funciona bien excepto survey.example.tech.

¿Que está sucediendo aquí? ¿Estoy entendiendo mal la configuración de subdominios con nginx?

Respuesta1

La configuración de nginx está bien.

Debe agregar un registro DNS que survey.example.techapunte a la dirección IP de su servidor.

información relacionada