Home > Mobile >  Nginx www to non www with page not working
Nginx www to non www with page not working

Time:09-22

I am using certbot for ssl in nginx. when i type https://www.example.com it redirect to https://example.com. But when I type https://www.example.com/article . It shows url not found.

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


}

CodePudding user response:

Add another certificate from certbot with this

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

and then add this certificate automatically to nginx conf with this -

sudo certbot --nginx
  • Related