簡體   English   中英

如何從 ngnix.conf 文件中解決基本 url 中的 www 問題

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

我的 ngnix.conf 文件如下所示.. 我試圖在瀏覽器中點擊www.example.com ,然后 url 被點擊就像https://www.www.example.com//這給了我錯誤。 網址https://example.com也不起作用。

    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;
    }

錯誤就像 -

您的連接不是私密的 攻擊者可能試圖從 example.com 竊取您的信息(例如,密碼、消息或信用卡)。 了解詳情NET::ERR_CERT_COMMON_NAME_INVALID

注意 - 我的證書還沒有過期..

我有一個答案。

我以前生成過證書,例如 -

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 \

現在我已經改變了我的證書生成程序,如下所示 -

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

這解決了我的問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM