본문 바로가기

Server/linux

[nginx ssl 설정] nginx ssl 설정 및 경고 메세지 처리

ssl 설정

server {
    listen       80;
    listen       443;
    server_name  도메인;

    ssl on;
    ssl_certificate /etc/nginx/conf.d/ssl/파일명_crt.pem;
    ssl_certificate_key /etc/nginx/conf.d/ssl/파일명_key.pem;
    ssl_session_timeout 5m;

    ssl_protocols TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHERSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    ssl_prefer_server_ciphers on;

    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        #root   /usr/share/nginx/html;
        #index  index.html index.htm;
        proxy_pass http://아이피:포트;
        index index.jsp;
    }

 

 

# 설정 정보 테스트 확인 : nginx -t

[root@xxxxx conf.d]# nginx -t
nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive instead in /etc/nginx/conf.d/default.conf:6
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

 

# 경고 메세지 :  nginx: [warn] the "ssl" directive is deprecated, use the "listen ... ssl" directive

 

 

# 설정 수정 하기 :  listen 443; ==>  listen 443 ssl;       ssl on; ==> 제거

server {
    listen       80;
    listen       443 ssl;
    server_name  도메인;
 
    ssl_certificate /etc/nginx/conf.d/ssl/파일명_crt.pem;
    ssl_certificate_key /etc/nginx/conf.d/ssl/파일명_key.pem;
    ssl_session_timeout 5m;

    ssl_protocols TLSv1.2;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHERSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    ssl_prefer_server_ciphers on;

 

 

# 설정 정보 테스트 확인 : nginx -t

[root@xxx conf.d]# nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

 

# 설정 정보 반영(리로드) : nginx -s reload

# 완료