Create TOC

2016년 11월 28일

nginx에 let's encrypt 인증서 적용

/etc/nginx/sites-available에 원하는 이름의 설정 파일을 만들고 아래와 같이 설정한다.

server {
 listen 443 ssl;
 listen [::]:443 ssl;
 server_name 서버명;
 root /var/www/html;

 add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
 add_header X-Frame-Options DENY;
 ssl on;
 ssl_certificate /etc/letsencrypt/live/서버명/fullchain.pem;
 ssl_certificate_key /etc/letsencrypt/live/서버명/privkey.pem;

 #OCSP Stapling
 ssl_dhparam /etc/nginx/ssl/서버명.dhparam;
 ssl_stapling on;
 ssl_stapling_verify on;
 ssl_trusted_certificate /etc/letsencrypt/live/서버명/fullchain.pem;
 resolver 8.8.8.8 8.8.4.4;

 ssl_protocols   TLSv1 TLSv1.1 TLSv1.2;
 ssl_ciphers 'ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128  -GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECD  HE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-  SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES25  6-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA';

 ssl_prefer_server_ciphers on;
 ssl_session_timeout 1d;
 ssl_session_cache shared:SSL:10m;

 # 이후 원하는 설정 추가
}

dhparam파일도 만든다.

$ sudo mkdir /etc/nginx/ssl
$ sudo openssl dhparam -out /etc/nginx/ssl/서버명.dhparam 2048

서버 설정 파일을 활성화시킨다

$ sudo ln -s /etc/nginx/sites-available/default /etc/nginx/sites-enabled/

설정에 문제가 없는지 테스트 해본다.

$ sudo nginx -t