2017-11-23 29 views
0
내가 nginx를 여러 사이트 에 배치 한

을/etc/nginx를/사이트 이용 가능한 최근에 내가 사이트 중 하나 letsencrypt와 HTTPS를 추가 한Nginx와 HTTPS를 잘못 사이트를 해결 유지

은 (의 말을하자 test1.com).

다른 모든 사이트에는 https가 구성되어 있지 않습니다.

이제 다른 사이트 (예 : test2.com)에 대해 https 요청을 한 경우

https://test2.com

나는

"연결이 비공개로 설정되어 있지 않습니다 경고의"그리고 nginx를가 https://test1.com 사이트를 열려고 크롬을 얻었다.

HTTP 요청이 정상적으로 작동합니다. 여기

여기 내 기본 conf의

server { 
    listen 80 default_server; 
    listen [::]:80 default_server; 

    listen 433 default_server; 
    listen [::]:433 default_server; 

    index index.php index.html index.htm index.nginx-debian.html; 


    location/{ 
     #try_files $uri $uri/ =404;i 
     try_files $uri $uri/ /index.php$is_args$args; 
    } 

    location ~ \.php$ { 
     include snippets/fastcgi-php.conf; 
     fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
    } 

    location ~ /\.ht { 
     deny all; 
    } 
} 

입니다 내가

# I've tried this - didn't help 
#server { 
# listen  433 ssl; 
# server_name www.test2.com; 
# return  444; 
#} 
server { 
     listen 80; 
     root /var/www/test2; 
     index index.php index.html index.htm; 
     server_name www.test2.com; 
     server_name test2.com; 

     location/{ 
        #try_files $uri $uri/ =404;i 
        try_files $uri $uri/ /index.php$is_args$args; 
     } 

     location ~ \.php$ { 
        include snippets/fastcgi-php.conf; 
        fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
     } 

     location ~ /\.ht { 
            deny all; 
     } 

} 

노력 아니에요 내 test2.com의 conf 파일입니다 내 TEST1 사이트의 conf 여기

server { 
     listen 80; 
     listen [::]:80; 
     server_name test1.com; 

     location/{ 
       return 301 https://www.test1.com$request_uri; 
     } 
} 

server { 
     listen 80; 
     listen [::]:80; 
     server_name www.test1.com; 

     location/{ 
       return 301 https://www.test1.com$request_uri; 
     } 
} 
server { 
     listen 443; 
     server_name www.test1.com; 
     ssl on; 

     ssl_session_timeout 1d; 
     ssl_session_cache shared:SSL:50m; 
     ssl_session_tickets off; 

     ssl_protocols TLSv1.2; 
     ssl_ciphers EECDH+AESGCM:EECDH+AES; 
     ssl_ecdh_curve secp384r1; 
     ssl_prefer_server_ciphers on; 

     ssl_stapling on; 
     ssl_stapling_verify on; 

     add_header Strict-Transport-Security "max-age=15768000; includeSubdomains; preload"; 
     add_header X-Frame-Options DENY; 
     add_header X-Content-Type-Options nosniff; 

     ssl_certificate /etc/letsencrypt/live/test1.com/fullchain.pem; 
     ssl_certificate_key /etc/letsencrypt/live/test1.com/privkey.pem; 


     root /var/www/test1; 

     index index.php index.html index.htm; 


     location/{ 
       try_files $uri $uri/ /index.php$is_args$args; 
     } 


     location ~ \.php$ { 
       include snippets/fastcgi-php.conf; 

       fastcgi_pass unix:/run/php/php7.0-fpm.sock; 

     } 
     location ~ /\.ht { 
       deny all; 
     } 

} 

입니다 test2.com에 대한 test1.com의 인증서를 사용하려면 https를 통해 작동하는 test2.com을 막으려 고합니다. test2.com 용 ssl을 만들면 제대로 작동하지만 원하지 않습니다. http없이 test2.com이 작동하고 https 요청에 대해 거부가 발생했습니다.

답변

0

HTTPS가 작동하는 방식은 xyz.com에 대한 인증서를 확인하여 브라우저와 사이트의 인증서가 일치하는지 확인하는 것입니다.

당신은 당신이 test2.com에 test1.com의 인증서를 사용하는 경우 귀하의 경우

에 test2.com 또 다른 인증서를 얻을 필요 브라우저는 인증서 표시가 일치하지 않는 있음을 알려줍니다 (즉, 웹 사이트가 아닙니다 test1.com)

업데이트

정의되지 않은 서버 이름을 방지하기 위해 conf의에서 아래의 블록을 넣어보십시오. 자사의 자동 경로 문제가있는 경우, 이것은 당신이 TEST2를 방지하려면 업데이트 2

server { 
    listen  80; 
    server_name ""; 
    return  444; 
} 

이 default.conf

listen 433 default_server; 
listen [::]:433 default_server; 
+0

나는 test2.com에 대한 SSL 인증서를 작성하면 올바르게 작동하지만 원치는 않습니다. 도메인이 많으며 대부분 https 연결이 필요하지 않습니다. 어떻게 든 https 요청을 거부 할 수 있습니까? – ivan133

+0

> HTTPS가 작동하는 방식은 xyz.com의 인증서를 확인하여 브라우저와 사이트의 인증서가 일치하는지 확인하는 것입니다. 저는 test2.com에 대해 test1.com의 인증서를 사용하려고하지 않고 있습니다. https를 통해 test2.com을 사용하지 못하도록 시도하고 있습니다. – ivan133

+0

죄송합니다. 내 잘못입니다. 귀하의 문제 진술서가 귀하의 요약본에서 사라지면 일부 서식을 사용하십시오. 그리고 귀하의 질문도 문제를 설명하는 방식으로 많이하지 않습니다 –

0

에서 다음 줄을 제거 해결 될 것입니다. co.kr에서 SSL 인증서를 사용하려면 :: return 444 대신 test2.com conf에서 :: 443 요청을 :: 80으로 리디렉션해야합니다.

server { 
     listen 443; 
     listen [::]:443; 
     server_name test2.com; 

     location/{ 
       return 301 http://www.test2.com$request_uri; 
     } 
} 
server { 
     listen 443; 
     listen [::]:443; 
     server_name www.test2.com; 

     location/{ 
       return 301 http://www.test1.com$request_uri; 
     } 
} 
server { 
     listen 80; 
     root /var/www/test2; 
     index index.php index.html index.htm; 
     server_name www.test2.com; 
     server_name test2.com; 

     location/{ 
        #try_files $uri $uri/ =404;i 
        try_files $uri $uri/ /index.php$is_args$args; 
     } 

     location ~ \.php$ { 
        include snippets/fastcgi-php.conf; 
        fastcgi_pass unix:/run/php/php7.0-fpm.sock; 
     } 

     location ~ /\.ht { 
            deny all; 
     } 

}