【问题标题】:Nginx www to non www with page not workingNginx www 到非 www 页面不工作
【发布时间】:2021-09-20 00:52:16
【问题描述】:

我在 nginx 中使用 certbot 进行 ssl。 当我输入https://www.example.com 时,它会重定向到https://example.com。 但是当我输入 https://www.example.com/article 时。它显示 url 未找到。

server {
        root /home/anjaan/dsjwl/backend/public;
        gzip            on;
        gzip_types      text/plain application/xml text/css application/javascr>
        gzip_min_length 1000;

        index index.php index.html index.htm index.nginx-debian.html;
        server_name desijewel.in;

       // My other configrations

 listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/desijewel.in/fullchain.pem; # managed>
    ssl_certificate_key /etc/letsencrypt/live/desijewel.in/privkey.pem; # manag>
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}


server {

   if ($host = desijewel.in) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

        listen 80;
        server_name desijewel.in;
    return 404; # managed by Certbot


}

【问题讨论】:

    标签: nginx


    【解决方案1】:

    用这个从 certbot 添加另一个证书

    sudo certbot certonly --expand -d www.example.com
    

    然后将此证书自动添加到 nginx conf 中 -

    sudo certbot --nginx
    

    【讨论】:

      猜你喜欢
      • 2011-12-18
      • 1970-01-01
      • 2015-03-07
      • 2014-07-12
      • 2015-02-13
      • 2017-01-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多