티스토리 뷰
사용한 도메인: devjh.tk, www.devjh.tk (ZeroSSL 무료플랜은 서브 도메인을 사용할 수 없다)
default.conf 경로: /etc/nginx/conf.d/default.conf (ubuntu 기준)
nginx.conf 경로: /etc/nginx/nginx.conf
호환 테스트 버전: nginx 1.22.1
SSL 인증서는 ZeroSSL(https://zerossl.com)에서 발급 받음
NGINX SSL에 적용하기 전 bundle.crt, certificate.crt 파일 cat 명령어를 사용하여 merge 필수
참고: https://help.zerossl.com/hc/en-us/articles/360058295894-Installing-SSL-Certificate-on-NGINX
SSL 파일을 /etc/nginx/ssl 에 넣고 작동시키면 끝.
.well-known 경로는 도메인 인증을 위해 사용
# /etc/nginx/conf.d/default.conf
# HTTP LISTEN
server {
listen 80;
server_name devjh.tk;
access_log /var/log/nginx/host.access.log main;
root /usr/share/nginx/html;
index index.html index.htm;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location ~^/.well-known/pki-validation {
allow all;
}
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
}
# HTTPS LISTEN
server {
listen 443 ssl;
server_name www.devjh.tk;
ssl_certificate /etc/nginx/ssl/certificate.crt; #merge된 파일
ssl_certificate_key /etc/nginx/ssl/private.key;
ssl_session_timeout 5m;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
# Nginx 배포 시 Route 에서 404 에러 날때
try_files $uri $uri/ /index.html;
}
}
# /etc/nginx/nginx.conf
user root;
worker_processes auto;
error_log /var/log/nginx/error.log notice;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
댓글