【问题标题】:how to make cerbot installed ssl work correctly?如何使 certbot install ssl 正常工作?
【发布时间】: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


    【解决方案1】:

    1- 在这里阅读我的答案: cannot install certbot on amazon linux2 nginx

    2- 确保您的 A 记录(用于您的域)或 CNAME 记录(用于您的子域)配置良好。

    3- 接下来通过为您的域或子域重新创建 ssl 证书来检查您的问题:

     sudo certbot --nginx 
    

    (在输出的某些地方,certbot 会询问您
    您要为其安装 ssl 的域名或子域)

    【讨论】:

      猜你喜欢
      • 2021-07-30
      • 2016-10-21
      • 2021-11-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多