1. pfx 파일을 crt 및 rsa로 변환 - convert pfx file to crt and rsa.

 $ openssl pkcs12 -in ssl.mysite.com.pfx  -clcerts -nokeys -out ssl.mysite.com.crt
 $ openssl pkcs12 -in ssl.mysite.com.pfx -nocerts -nodes -out ssl.mysite.com.rsa


2. crt rsa파일 복사 - copy crt and rsa file to NGINX_HOME/conf/ssl/

C:\Users\fehead> dir /w C:\nginx\conf\ssl

C:\nginx\conf\ssl
[.]                 [..]                ssl.mysite.com.crt   ssl.mysite.com.rsa
C:\Users\fehead>




3. nginx config 파일 설정 - set nginx config file.

######################################################################################################################################################
### nginx config.

# tomcat

upstream    tomcat {
    server    127.0.0.1:8080    fail_timeout=0;
}

# ssl.mysite.com https setting
server {
        server_name ssl.mysite.com;

        location / {
                proxy_redirect off;
                proxy_pass_header Server;

                proxy_set_header Host $http_host;
                proxy_set_header X-Forwarded-Proto $scheme;
                proxy_set_header X-Forwarded-Port $server_port;
                proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
                proxy_set_header X-Real-IP $remote_addr;
                proxy_set_header X-Scheme $scheme;
                proxy_pass http://tomcat;
                charset utf-8;
        }

    listen [::]:443 ssl;
    listen 443 ssl;
    ssl on;
    ssl_certificate    ssl/ssl.mysite.com.crt;
    ssl_certificate_key    ssl/ssl.mysite.com.rsa;

}


# ssl.mysite.com SSL redirect
server {
    listen 80;
    listen [::]:80;

    server_name ssl.mysite.com;   

    return 301 https://$host$request_uri;   
}


# Etc Site
server {
    listen 80;
    listen [::]:80;

    server_name etc.mysite.com;   
    ...

}



4. test nginx config

C:\nginx>nginx.exe -t
nginx: the configuration file C:\nginx/conf/nginx.conf syntax is ok
nginx: configuration file C:\nginx/conf/nginx.conf test is successful

C:\nginx>


5. restart nginx


C:\nginx>nginx.exe -s reload


+ Recent posts