【发布时间】:2021-09-24 18:19:04
【问题描述】:
我确实在数字海洋上设置了我的网站,我确实使用了ubuntu 20.04 vm,该网站是基本的 mern 应用程序,我确实使用了nginx 1.18.0 作为反向代理,初始 nginx 配置就是这样
server {
listen 80
server_name kwarezma.one www.kwarezma.one;
location / {
proxy_pass http://127.0.0.1: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;
proxy_redirect off;
}
location /api {
# This is my nodejs API
proxy_pass http://127.0.0.1:5000;
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;
}
}
我的 conf 路径是 /etc/nginx/sites-available/default
使用 certbot 安装 ssl 后,我的配置更改为这个
server {
server_name kwarezma.one www.kwarezma.one;
location / {
proxy_pass http://127.0.0.1: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;
proxy_redirect off;
}
location /api {
# This is my nodejs API
proxy_pass http://127.0.0.1:5000;
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;
}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/kwarezma.one/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/kwarezma.one/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.kwarezma.one) {
return 301 https://$host$request_uri;
} # managed by Certbot
if ($host = kwarezma.one) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
server_name kwarezma.one www.kwarezma.one;
return 404; # managed by Certbot
}
但现在当我访问我的网站 kwarezma.one 或 www.kwarezma.com 时,它的讲解员工作,我不知道发生了什么,所以这里的任何帮助将不胜感激
【问题讨论】:
标签: nginx digital-ocean certbot