티스토리 뷰

Developer

[ SSL ] nginx + ssl

rocksea 2012. 7. 4. 15:28

 

이번엔 Nginx + SSL 설치 및 사용법에 대하여 알아보도록 하겠습니다.

step 1. 소스 다운로드

# wget 'http://nginx.org/download/nginx-1.3.2.zip'

 

step 2. configure & make

 # ./configure --prefix=/usr/local/nginx --with-http_ssl_module  --without-http_rewrite_module

# make

# make install

 

step3. key 생성

# openssl req -new > rocksea.csr

.....++++++
............................++++++
writing new private key to 'privkey.pem'
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
phrase is too short, needs to be at least 4 chars
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [GB]:KR
State or Province Name (full name) [Berkshire]:Seoul
Locality Name (eg, city) [Newbury]:rocksea
Organization Name (eg, company) [My Company Ltd]:rocksea
Organizational Unit Name (eg, section) []:rocksea
Common Name (eg, your name or your server's hostname) []:rocksea
Email Address []:globalrocksea@gmail.com

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:1234
An optional company name []:rocksea

# openssl rsa -in privkey.pem -out rocksea.key

Enter pass phrase for privkey.pem:
writing RSA key

# openssl x509 -in rocksea.csr -out rocksea.cert -req -signkey rocksea.key -days 36500

 

step 4. nginx 설정 파일 추가

# vi /usr/local/nginx/conf/nginx.conf 

    server {
        listen       443;
        server_name  localhost;

        ssl                  on;
        ssl_certificate      /usr/local/nginx/keys/rocksea/rocksea.cert;
        ssl_certificate_key  /usr/local/nginx/keys/rocksea/rocksea.key;

        ssl_session_timeout  5m;

        ssl_protocols  SSLv2 SSLv3 TLSv1;
        ssl_ciphers  HIGH:!aNULL:!MD5;
        ssl_prefer_server_ciphers   on;

        location / {
            root   html;
            index  index.html index.htm;
        }
    }

 

step 5. browser 확인

https://ip:443 으로 접속하여 확인

 

기쁜 마음으로 다른 포스팅을 작성할 수 있도록 view on 한번씩 꾹 눌러주는 센스^^

이상 nginx + ssl 포스팅을 마치도록 하겠습니다.

by rocksea.

댓글