페이지

[ubuntu] SSL(https) 적용하기 (작업중)


1. openSSL 설치
$ sudo apt-get install openssl

2. 개인 Key 생성
$ sudo openssl genrsa –des3 -out keyname.key 2048

3. CRS 생성
$ sudo openssl req –new –key keyname.key > csr.pem
// 또는
$ sudo openssl req –new –key keyname.key -out csr.pem

4. CRS 내용을 인증기관에 전달
5. 인증 기관에서 발급된 인증서를 파일로 저장(cert.pem)


SSL 모듈 활성화
$ sudo a2enmod ssl

Key 파일 암호 제거(불편한 경우)
$ sudo openssl rsa -in keyname.key -out keyname_no_pass.key

방화벽을 사용중인 경우 443 포트 개방
$ sudo ufw allow https

가상호스트(VirtualHost) 설정 파일에 적용하는 경우(예시)
<VirtualHost *:443>
    ServerName domain.com

    ServerAdmin name@email.com
    ServerAlias www.domain.com *.domain.com

    DocumentRoot /html/directory

    <Directory /html/directory>  
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>  

    SSLEngine on
    SSLProtocol all -SSLv2 -SSLv3
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM
    SSLHonorCipherOrder on
    # 인증서 파일 (5번)
    SSLCertificateFile "/ssl_directory/cert.pem"
    # 개인키 파일 (2번)
    SSLCertificateKeyFile "/ssl_directory/keyname.key"
    # 체인 인증서 (확장자가 .ca-bundle 인 경우도 있음)
    SSLCertificateChainFile "/ssl_directory/cert.cer"

    ErrorDocument 402 /missing.html
    ErrorDocument 403 "/cgi-bin/cgi-script.pl"
    ErrorDocument 404 error.domain.com
    ErrorDocument 500 "Internal Server Error"

    ErrorLog ${APACHE_LOG_DIR}/domain-error.log  
    CustomLog ${APACHE_LOG_DIR}/domain-access.log combined
</VirtualHost>

[ubuntu] 아파치 기본 디렉토리 변경



* 우분투 버전: 16.04 LTS
1. 아파치 기본 디렉토리(/var/www/) 변경시 필요한 설정(기본 웹페이지 변경)
2. 디폴트 사이트 설정 화일(000-default.conf) 수정
# /etc/apache2/sites-available/000-default.conf
<VirtualHost *:80>
    ...
    DocumentRoot /사용할 디렉토리 (기존 /var/www 수정)
    ...
</VirtualHost>

3. apache2.conf에 코드 추가 또는 기존 디렉토리(/var/www/) 설정 수정
# /etc/apache2/apache2.conf
<Directory /사용할 디렉토리/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
</Directory>

4. 아파치 재시작
$ sudo service apache2 restart (or reload)