Next.js HTTPSの適用
Install nginx
sudo apt update
sudo apt install nginx
sudo ufw app list
sudo ufw allow 'Nginx HTTP'
systemctl start nginx
Configure nginx
cd /etc/nginx/sites-available
vi 도메인
# *q is our domain, replace port 3000 with your port number
server {
listen 80;
listen [::]:80;
root /var/www/html;
index index.html index.htm index.nginx-debian.html;
server_name 도메인 www.도메인;
location / {
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
# for letsencrypt
location ~ /.well-known {
allow all;
}
}
/etc/nginx/sites-available
パスに도메인
ファイルを作成し、必要に応じて置き換えます.sudo ln -s /etc/nginx/sites-available/도메인 /etc/nginx/sites-enabled/도메인
nginx -t
service nginx restart
Install certbot
sudo apt update && sudo apt install certbot python3-certbot-nginx
Configure certbot
certbot --nginx -d 도메인 -d www.도메인
certbot certonly --standalone --preferred-challenges http -d 도메인
certbot renew --dry-run
Auto renew certificate
crontab -e
0 12 * * * /usr/bin/certbot renew --quiet
サーバ上の証明書が毎日昼の次の30日以内に期限切れになり、期限切れになったときに再発行されることを確認するコマンドを実行します.--quiet
はcertbotが出力を生成することを許可しないオプションである.Reference
この問題について(Next.js HTTPSの適用), 我々は、より多くの情報をここで見つけました https://velog.io/@gwak2837/Next.js-HTTPS-적용하기テキストは自由に共有またはコピーできます。ただし、このドキュメントのURLは参考URLとして残しておいてください。
Collection and Share based on the CC Protocol