日本免费高清视频-国产福利视频导航-黄色在线播放国产-天天操天天操天天操天天操|www.shdianci.com

學無先后,達者為師

網站首頁 編程語言 正文

Nginx將http轉換成https的詳細過程_nginx

作者:Little___Turtle ? 更新時間: 2022-07-08 編程語言

http 大家都知道是不安全的 然后想換成https

申請ssl證書

1.你得先有ssl證書(阿里云為例)

然后就是配置一下

審核完成之后就是下載證書了

下載完會有一個壓縮包

你把壓縮包解壓放入你nginx.conf目錄下就可以了

/www/server/nginx/conf?(寶塔對應的目錄)

重點來了

配置

nginx.conf

  server {
        listen       443 ssl;
        #存放域名或者你服務的路徑
        server_name localhost;
        #把證書放進conf目錄下 然后就是對應著填寫
        ssl_certificate xxxxxx.pem;
        ssl_certificate_key xxxxx.key;

        #access_log  logs/host.access.log  main;
        #后臺管理靜態資源存放
      location / { 
          #文件目錄
          root  html;
          #首頁的樣式
          index  index.html;
        }
      location /prod-api { 
        #反向代理
          proxy_pass xxxx.xxxx.xxxx;
        }

  }
  server {
        listen       80;

       #域名
        server_name  xxxx.xxx.com xxxx.com;

    #讓所有訪問80端口 http 的都跳轉到443 也就是https
        return 301 https://$server_name$request_uri;
        root html;
      }

成果展示:

總結

原文鏈接:https://blog.csdn.net/Little___Turtle/article/details/124736823

欄目分類
最近更新