Nginx 잘못된 호스트 오류

Nginx 잘못된 호스트 오류

Nginx 구성 파일에 오류가 발생했습니다.

실행하면 systemctl status nginx.service다음과 같은 결과를 얻습니다.

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

내 구성 파일은 다음과 같습니다.

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;
    }
}

저는 Nginx를 NodeJS 서버(Meteor 앱 실행)에 대한 역방향 프록시로 사용하고 있습니다.

내가 어디서 잘못됐나요?

답변1

listen [::]443당신은 있어야 할 때를 가지고 있습니다 listen [::]:443.

관련 정보