hymn

忽有故人心头过,回首山河已是秋。

  menu
132 文章
0 浏览
0 当前访客
ღゝ◡╹)ノ❤️

nginx 配置 https

server {
    listen 443 ssl;   #SSL协议访问端口号为443。此处如未添加ssl,可能会造成Nginx无法启动。
    server_name www.dxyhymn.com;  #将localhost修改为您证书绑定的域名,例如:www.example.com。
    ssl_certificate /usr/local/nginx/cert/4188121_www.dxyhymn.com.pem;   #将domain name.pem替换成您证书的文件名。
    ssl_certificate_key /usr/local/nginx/cert/4188121_www.dxyhymn.com.key;   #将domain name.key替换成您证书的密钥文件名。
    ssl_session_timeout 5m;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;   #使用该协议进行配置。

    #ssl_protocols  SSLv2 SSLv3 TLSv1; #这个配置浏览器会显示不是安全连接
    ssl_ciphers  HIGH:!aNULL:!MD5;

    ssl_prefer_server_ciphers on;

    location / {
        proxy_pass http://backend$request_uri;
        proxy_set_header  Host $http_host;
        proxy_set_header  X-Real-IP $remote_addr;
        client_max_body_size  10m;
    }
    location /img {
        alias  /usr/local/hymn/img/;
        autoindex on;
    }

}


server {
        listen       80;
        server_name  www.dxyhymn.com; # 博客域名

        access_log off;

        location / {
                rewrite ^(.*)$ https://$host$1 permanent;   #将所有http请求通过rewrite重定向到https。
        }
    }

踩到的坑:

配置完后浏览器显示

image.png

  1. 审查元素,有图片的地址是http的,修改为https
  2. ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用该协议进行配置。
  3. #ssl_protocols SSLv2 SSLv3 TLSv1; #这个配置浏览器会显示不是安全连接

标题:nginx 配置 https
作者:hymn
地址:https://dxyhymn.com/articles/2020/07/10/1594362225103.html