Erro de host inválido Nginx

Erro de host inválido Nginx

Estou recebendo um erro no meu arquivo de configuração do Nginx.

Correndo systemctl status nginx.serviceeu recebo:

Mar 08 19:32:26 ansible-test nginx[1118]: nginx: [emerg] invalid host in "[::]443" of the "listen" directive in /etc/nginx/sites-enabled/www.mywebsite.org.conf:78
Mar 08 19:32:26 ansible-test nginx[1118]: nginx: configuration file /etc/nginx/nginx.conf test failed
Mar 08 19:32:26 ansible-test systemd[1]: nginx.service: Control process exited, code=exited status=1

Aqui está meu arquivo de configuração:

add_header Content-Security-Policy "default-src 'self'  ... ;

add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always;

add_header X-Content-Type-Options nosniff;

add_header X-Frame-Options SAMEORIGIN;

add_header X-XSS-Protection "1; mode=block";

server_tokens off;

server {
  listen [::]:80;
  listen 80;
    server_name subdomain.mywebsite.org;
  return 301 https://$server_name$request_uri;
}


server {
  listen [::]:80;
  listen 80;
    server_name www.mywebsite.org;
  return 301 https://$server_name$request_uri;
}

server {
  listen [::]:80;
  listen 80;
    server_name mywebsite.org;
  return 301 https://www.mywebsite.org/$request_uri;
}

proxy_cache_path /var/www/mywebsite/cache levels=1:2 keys_zone=mywebsite_cache:10m max_size=10g
                 inactive=60m use_temp_path=off;

server {
         listen [::]443 ssl http2 default_server;
         listen 443 ssl http2 default_server;

            ssl on;
      ssl_certificate /etc/nginx/ssl/myCA.pem;
      ssl_certificate_key /etc/nginx/ssl/myCA.key;

    location /blah.html { alias /var/www/mywebsite/static_assets/blah.html; }
    location /robots.txt { alias /var/www/mywebsite/static_assets/robots.txt; }
    location /img { alias /var/www/mywebsite/static_assets/img; }
    location /files { alias /var/www/mywebsite/static_assets/files; }

    location / {
        proxy_cache mywebsite_cache;
        proxy_pass http://localhost:3000;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
    }
}

Estou usando o Nginx como proxy reverso para um servidor NodeJS (executando um aplicativo Meteor).

Onde foi que eu errei?

Responder1

Você tem listen [::]443quando deveria listen [::]:443.

informação relacionada