1 노드 포트를 3000-4000 으로 여러포트를 열어 준다.
2 sudo certbot --nginx // certbot 설치 되었다고 가정
3 도메인마다 https 인증 받은 뒤,
4. vi /etc/nginx/nginx.conf 파일 변경하기
events{}
http {
server {
if ($host = 도메인주소A) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name yushin.kr;
return 301 https://yushin.kr$request_uri;
}
server {
if ($host = 도메인주소B;) {
return 301 https://$host$request_uri;
} # managed by Certbot
server_name test.yushin.kr;
return 301 https://test.yushin.kr$request_uri;
}
server {
listen 443 ssl;
server_name 도메인 주소 A;
ssl_certificate /etc/letsencrypt/live/도메인 주소A/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/도메인주소A/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:3000;
proxy_redirect off;
}
}
server {
listen 443 ssl;
server_name 도메인주소B;
ssl_certificate /etc/letsencrypt/live/도메인주소B/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/도메인주소 B/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem;
location / {
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:3001;
proxy_redirect off;
}
}
}