RadarURL

웹서버,WAS
2025.09.10 19:27

아파치2(Apache2) SSL HTTPS 적용하기

Views 0 Votes 0 Comment 0
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print
?

Shortcut

PrevPrev Article

NextNext Article

Larger Font Smaller Font Up Down Go comment Print

서버환경: Ubuntu 16.04(xenial), Apache2, PHP7

홈페이지에 들어가면 뜨는 아래의 문구가 계속 거슬렸다 ㅋㅋ
이걸 없애려면 Https로 접속을 시켜야 한다.





HTTPS로 접속하기 위해선 SSL 인증서가 필요!
이 SSL 인증서를 아파치 및 도메인에 설정해줘야 한다. 그런데 대부분 SSL 인증서가 유료다.
그 중 Encrypt에서 무료로 SSL 인증서를 발급해 준다는 것을 알아냈다.
Encrypt 홈페이지에 들어가 보면 Certbot 이라는 프로그램을 통해 자동으로 SSL을 적용하기를 권한다.
하지만 나는 어떻게 돌아가는지 알고 싶어서 수동으로 적용하기로 했다.

Certbot

certbot.eff.org






수동으로 할 경우, SSL 인증서를 다운로드 받고 아파치 설정파일에서 다운받은 SSL 인증서를 명시해주면 된다.
나는 [http://hwanstore.ml]를 [https://hwanstore.ml]로 변신시킬 거다.
그러기 위해서 hwanstore.ml 도메인에 대한 SSL 인증서를 받아야 한다.
 

1. SSL 인증서 다운받기


먼저 apt-get 업데이트를 한 번 해주고 letsencrypt를 설치해준다.

$ sudo apt-get update $ sudo apt-get install letsencrypt



그다음 SSL 인증서를 받기 위한 명령어를 쳐야 하는데,
이 명령어가 실행될 때 80포트를 사용하기 때문에 80포트를 비워줘야 한다.
아파치가 기본적으로 80포트에 물려 있기 때문에 아파치를 꺼준다.

$ sudo service apache2 stop

현재 사용 포트 확인은

$ netstat -ant



80포트가 없는 걸 확인 후 인증서를 받는 명령어를 친다.

$ sudo letsencrypt certonly --standalone -d hwanstore.ml



이메일을 입력하고 Agree를 하면
아래와 같이 나온다.
/etc/letsencrypt/live/hwanstore.ml 디렉터리에 인증서가 저장되었다고 한다.

IMPORTANT NOTES: - Congratulations! Your certificate and chain have been saved at /etc/letsencrypt/live/hwanstore.ml/fullchain.pem. Your cert will expire on 2017-06-03. To obtain a new version of the certificate in the future, simply run Let's Encrypt again. - If you like Let's Encrypt, please consider supporting our work by: Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate Donating to EFF: https://eff.org/donate-le //해당 경로로 가보면 인증서 관련 파일들이 만들어져 있다. root@ubuntu:/etc/letsencrypt/live/hwanstore.ml# ls cert.pem chain.pem fullchain.pem privkey.pem



80포트 사용이 끝났으니 다시 아파치를 실행시켜 준다.

$ sudo service apache2 start


 

2. 아파치에 SSL 인증서 설정하기

ssl 사용을 하겠다고 명시

$ sudo a2enmod ssl



아래 경로로 이동

$ cd /etc/apache2/sites-available



default-ssl.conf 파일을 원하는 이름으로 복사!

$ cp default-ssl.conf hwanstore.ml-ssl.conf



문서 편집기로 해당 파일을 열어서 수정을 해준다.
전체 내용이 너무 길어서 바꾼 부분만 쓴다. (주석 해재 후 수정)

$ sudo nano hwanstore.ml-ssl.conf //문서 편집기로 파일 열기 ServerAdmin ameeuk@gmail.com ServerName hwanstore.ml ServerAlias hwanstore.ml DocumentRoot /var/www/test //웹문서 경로 SSLEngine on //SSL 인증서 명시 SSLCertificateFile /etc/letsencrypt/live/hwanstore.ml/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/live/hwanstore.ml/privkey.pem



a2ensite 명령어로 방금 수정한 파일을 site에 등록 후 아파치 재시작

$ sudo a2ensite hwanstore.ml-ssl.conf $ sudo service apache2 restart



그리고 나서 https://hwanstore.ml로 접속하면!
우왕! 녹색 자물쇠와 함께 안전함!




추가로, http로 접속을 해도 https로 접속되게 만드려면
VirtualHost 설정에서
Redirect permanent / https://hwanstore.ml 을 추가해주면 된다.

<VirtualHost *:80> ServerName hwanstore.ml DocumentRoot /var/www/test Redirect permanent / https://hwanstore.ml/ <Directory /var/www/test/> Options Indexes FollowSymLinks MultiViews AllowOverride All </Directory> </VirtualHost>

 

 

 

출처 : https://blog.naver.com/ameeam/220950594646

?

공부 게시판

공부에 도움되는 글을 올려주세요.

  1. [공지] 공부 게시판 입니다.

    Date2003.08.18 By처누 Views928087
    read more
  2. http를 https로 리다이렉트하는 여러가지 방법

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views0
    Read More
  3. SSL인증서 없이 HTTPS에서 HTTP로 되돌리기

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views2
    Read More
  4. [SSL] win-acme, Let's encrypt로 무료 SSL 인증서 발급

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views0
    Read More
  5. [SSL] Windows 10에서 Let's Encrypt로 SSL 인증서 무료 발급받기

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views0
    Read More
  6. 무료로 https SSL/TLS 인증서를 발급받을 수 있는 인증 기관

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views0
    Read More
  7. 아파치 서버에 https SSL 인증서 적용하는 방법 (apache httpd)

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views0
    Read More
  8. 아파치2(Apache2) SSL HTTPS 적용하기

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views0
    Read More
  9. 아파치 웹서버에 멀티 도메인에 대한 80, 443 포트 설정하는 방법

    Date2025.09.10 Category웹서버,WAS ByJaeSoo Views0
    Read More
  10. Google Photo 대신 Immich를 써보자

    Date2025.08.07 Category소프트웨어 ByJaeSoo Views126
    Read More
  11. [사진관리] PhotoPrism vs LibrePhoto 비교 소감

    Date2025.05.19 Category소프트웨어 ByJaeSoo Views14
    Read More
  12. 윈도우 자동 로그온 설정이 보이지 않을 때 조치사항

    Date2024.08.16 Category윈도우즈 ByJaeSoo Views203
    Read More
  13. 핸드폰 연락처 한방에 깔끔하게 정리하기 - by.컨택에디터(Contact Editor)

    Date2024.05.27 Category소프트웨어 ByJaeSoo Views31
    Read More
  14. Rufus 로 윈도우10 usb 디스크를만들때 UEFI,Legacy 설정 (4G 이상 부팅 이미지 GPT)

    Date2023.11.20 Category윈도우즈 ByJaeSoo Views2260
    Read More
  15. Windows 11에서 모든 시스템 트레이 아이콘을 관리하고 표시하는 방법

    Date2023.11.05 Category윈도우즈 ByJaeSoo Views1367
    Read More
  16. 윈도우11 작업 표시줄 좌/우/상/하 이동 및 두 줄 만드는 방법

    Date2023.11.05 Category윈도우즈 ByJaeSoo Views1250
    Read More
  17. 윈도우11의 마우스 오른쪽 버튼 메뉴, 기존 윈도우 형태로 되돌리는 방법

    Date2023.10.25 Category윈도우즈 ByJaeSoo Views913
    Read More
  18. [Msoffice] Pdfmaker office addin 오류 해결방법

    Date2023.08.21 Category윈도우즈 ByJaeSoo Views3775
    Read More
  19. [U2L] Unix to Linux 기대효과 분석

    Date2023.05.16 Category유닉스/리눅스 ByJaeSoo Views1258
    Read More
  20. 리눅스 inodes full 이슈 해결 방법

    Date2023.05.02 Category유닉스/리눅스 ByJaeSoo Views169
    Read More
  21. inode full

    Date2023.05.01 Category유닉스/리눅스 ByJaeSoo Views115
    Read More
Board Pagination Prev 1 2 3 4 5 6 7 8 9 10 ... 33 Next
/ 33


즐겨찾기 (가족)

JAESOO's HOMEPAGE


YOUNGAE's HOMEPAGE


장여은 홈페이지


장여희 홈페이지


장여원 홈페이지


즐겨찾기 (업무)

알리카페 홀릭

숭실대 컴퓨터 통신연구실 (서창진)

말레이시아 KL Sentral 한국인 GuestHouse


즐겨찾기 (취미)

어드민아이디

유에코 사랑회

아스가르드 좋은사람/나쁜사람

JServer.kr

제이서버 메타블로그

재수 티스토리


즐겨찾기 (강의, 커뮤니티)

재수 강의 홈페이지


한소리


VTMODE.COM


숭실대 인공지능학과


숭실대 통신연구실


베너