简体   繁体   中英

How to resolve www issue in base url from ngnix.conf file

My ngnix.conf file is as shown below.. I am trying to hit www.example.com in browser, then the url is getting hit is like https://www.www.example.com// and this gives me en error. Also the url https://example.com is not working.

    server {
    #server_names_hash_bucket_size  64;
    listen 80;
    server_name *.example.com www.example.com example.com;
    server_tokens off;
    # Redirects http to https
    location / {
        #return 301 https://$host$request_uri;

        #non www to www
        rewrite ^(.*) https://www.$host$request_uri$1 permanent;
    }

The error is like -

Your connection is not private Attackers might be trying to steal your information from example.com (for example, passwords, messages or credit cards). Learn moreNET::ERR_CERT_COMMON_NAME_INVALID

Note - My certificate is not expired yet..

I have got an answer.

I have generated certificate previously like -

sudo certbot certonly --manual \
  --preferred-challenges=dns \
  --email asdf@example.com \
  --server https://acme-v02.api.letsencrypt.org/directory \
  --agree-tos \
  --manual-public-ip-logging-ok \
  -d *.example.com \

Now I have changed my certificate generation procedure like as follows -

sudo certbot certonly --manual \
  --preferred-challenges=dns \
  --email asdf@example.com \
  --server https://acme-v02.api.letsencrypt.org/directory \
  --agree-tos \
  --manual-public-ip-logging-ok \
  -d *.example.com \
  -d example.com

This resolved my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM