여기서는 IP 주소에 대해 도메인 연결이 된 경우에 대해서 설명한다.
yowb.org, www.yowb.org에 대해 도메인 연결이 되어있다고 가정한다.
프로젝트이름.conf
로 하면 된다.http://[ip]:[port]
로 지정 가능하다.server {
listen 80;
listen [::]:80;
server_name yowb.org www.yowb.org;
location / {
proxy_pass http://unix:/home/somnode/YOWB/gunicorn.sock;
}
}
sudo add-apt-repository ppa:certbot/certbot # 최신 리눅스 버전에서는 추가 안해도 설치 가능한 것 같음.
sudo apt-get install python3-certbot-nginx -y
-d
뒤에 https 적용을 위해 인증서를 발급받을 도메인을 입력한다.sudo certbot --nginx -d yowb.org www.yowb.org
1: No redirect - Make no further changes to the webserver configuration.
2: Redirect - Make all requests redirect to secure HTTPS access. Choose this for
new sites, or if you're confident your site works on HTTPS. You can undo this
change by editing your web server's configuration.
sudo certbot certificates
server {
server_name yowb.org www.yowb.org;
location / {
proxy_pass http://unix:/home/somnode/flask/YOWB/gunicorn.sock;
}
listen [::]:443 ssl; # managed by Certbot
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/www.yowb.org/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/www.yowb.org/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.yowb.org) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = yowb.org) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name yowb.org www.yowb.org;
return 404; # managed by Certbot
}