Nginx SSL 인증서 설치[CentOS 7]
Nginx SSL 인증서 설치를 진행합니다.
1. 인증서 신청하기
SSL 인증서는 30일 무료 SSL을 https://zerossl.com/ 사이트에서 신청했습니다.
![Nginx SSL 인증서 설치[CentOS 7] 1 Nginx SSL 설치-Free 30일 신청 1](https://uknew.co/wp-content/uploads/2025/06/Nginx-SSL-%EC%84%A4%EC%B9%98-Free-30%EC%9D%BC-%EC%8B%A0%EC%B2%AD-1-1024x776.png)
![Nginx SSL 인증서 설치[CentOS 7] 2 Nginx SSL 설치-Free 30일 신청 2](https://uknew.co/wp-content/uploads/2025/06/Nginx-SSL-%EC%84%A4%EC%B9%98-Free-30%EC%9D%BC-%EC%8B%A0%EC%B2%AD-2-1024x510.png)
![Nginx SSL 인증서 설치[CentOS 7] 3 Nginx SSL 설치-Free 30일 신청 3](https://uknew.co/wp-content/uploads/2025/06/Nginx-SSL-%EC%84%A4%EC%B9%98-Free-30%EC%9D%BC-%EC%8B%A0%EC%B2%AD-3-1024x707.png)
DCV 인증은 DNS 인증 방식으로 진행했습니다.
![Nginx SSL 인증서 설치[CentOS 7] 4 Nginx SSL 설치-Free 30일 신청 4_DEV DNS 인증](https://uknew.co/wp-content/uploads/2025/06/Nginx-SSL-%EC%84%A4%EC%B9%98-Free-30%EC%9D%BC-%EC%8B%A0%EC%B2%AD-4_DEV-DNS-%EC%9D%B8%EC%A6%9D-1024x608.png)
네임서버에서 CNAME 레코드를 설정합니다.
![Nginx SSL 인증서 설치[CentOS 7] 5 Nginx SSL 설치-Free 30일 신청 4_DEV DNS 인증2](https://uknew.co/wp-content/uploads/2025/06/Nginx-SSL-%EC%84%A4%EC%B9%98-Free-30%EC%9D%BC-%EC%8B%A0%EC%B2%AD-4_DEV-DNS-%EC%9D%B8%EC%A6%9D2.png)
설정 후 인증 신청을 한 후 대기 시간이 소요됩니다.
![Nginx SSL 인증서 설치[CentOS 7] 6 Nginx SSL 설치-Free 30일 신청 5](https://uknew.co/wp-content/uploads/2025/06/Nginx-SSL-%EC%84%A4%EC%B9%98-Free-30%EC%9D%BC-%EC%8B%A0%EC%B2%AD-5-1024x567.png)
인증이 완료되면 인증서 파일을 다운로드 받은 후 서버에 인증서 설치 작업을 진행합니다.
![Nginx SSL 인증서 설치[CentOS 7] 7 Nginx SSL 설치-Free 30일 신청 6](https://uknew.co/wp-content/uploads/2025/06/Nginx-SSL-%EC%84%A4%EC%B9%98-Free-30%EC%9D%BC-%EC%8B%A0%EC%B2%AD-6-1024x712.png)
2. 방화벽 설정
윈도우 처음 설치 후 특별한 설정을 하지 않았다면 기본 방화벽은 firewallD 데몬입니다.
firewall-cmd --permanent --add-service=https
firewall-cmd --reload3. ssl 인증서 업로드
lrzsz 툴을 설치 후 드래그 하여 파일을 업로드 합니다.
cd /etc/nginx/
mkdir ssl
yum -y install lrzsz4. user.conf SSL 적용
기존 80번 포트의 서버 블록에서 추가로 443 포트의 SSL 적용할 서버 블록을 만들어서 SSL 인증서 적용할 내용을 추가합니다.
# http 서버 블록
server {
listen 80;
server_name mydomain.com;
#http로 접속할 경우 https로 리다이렉트
return 301 https://$host$request_uri;
location / {
root /home/testuser/www;
index index.html index.htm index.php;
charset utf-8;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
location ~ \.php$ {
root /home/testuser/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
# HTTPS 서버 블록 설정 추가
server {
listen 443 ssl;
server_name mydomain.com;
ssl_certificate /etc/nginx/ssl/certificate.crt;
ssl_certificate_key /etc/nginx/ssl/private.key;
root /home/testuser/www;
index index.html index.htm index.php;
charset utf-8;
location / {
try_files $uri $uri/ =404;
}
location ~ \.php$ {
root /home/testuser/www;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
}Nginx 서버 블록
├── HTTP 서버 블록 (포트 80)
│ ├── server_name: localhost; or domain(mydomain.com)
│ ├── 리다이렉트: http → https (return 301 https://$host$request_uri)
│ ├── location /
│ │ ├── root: /home/testuser/www
│ │ ├── index: index.html, index.htm, index.php
│ │ └── charset: utf-8
│ ├── location = /50x.html
│ │ └── root: /usr/share/nginx/html
│ └── location ~ \.php$
│ ├── root: /home/testuser/www
│ ├── fastcgi_pass: 127.0.0.1:9000
│ ├── fastcgi_index: index.php
│ ├── fastcgi_param: SCRIPT_FILENAME = $document_root$fastcgi_script_name
│ └── include: fastcgi_params
│
├── HTTPS 서버 블록 (포트 443 ssl)
├── server_name: localhost; or domain(mydomain.com)
├── ssl_certificate: /etc/nginx/ssl/certificate.crt
├── ssl_certificate_key: /etc/nginx/ssl/private.key
├── root: /home/testuser/www
├── index: index.html, index.htm, index.php
├── charset: utf-8
├── location /
│ └── try_files: $uri $uri/ =404
├── location ~ \.php$
│ ├── root: /home/testuser/www
│ ├── fastcgi_pass: 127.0.0.1:9000
│ ├── fastcgi_index: index.php
│ ├── fastcgi_param: SCRIPT_FILENAME = $document_root$fastcgi_script_name
│ └── include: fastcgi_params
└── location = /50x.html
└── root: /usr/share/nginx/html5. Nginx 재시작 및 SSL 인증서 적용 사항 확인
nginx -s reloadNginx SSL 인증서가 정상적으로 설치 되었습니다.
![Nginx SSL 인증서 설치[CentOS 7] 8 Nginx SSL 설치 웹에서 확인하기](https://uknew.co/wp-content/uploads/2025/06/Nginx-SSL-%EC%84%A4%EC%B9%98-%EC%9B%B9%EC%97%90%EC%84%9C-%ED%99%95%EC%9D%B8%ED%95%98%EA%B8%B0-1024x730.png)