nginx配置记录

  1. 启用https
    1. 1.购买免费证书
    2. 2.补全证书信息
    3. 3.下载并配置

启用https

1.购买免费证书

登录阿里云 -> 控制台 -> 安全(云盾) -> CA证书服务 -> 购买证书
购买免费证书

2.补全证书信息

点击补全,绑定域名

3.下载并配置

选择下载 证书for nginx
下载证书

上面这个页面有相关的配置信息,下面简单介绍:

① 将下载文件中的 *.pem*.key, 拷贝到 nginx 目录下 的 cert , 当然也可以是其他目录
② 修改 nginx.conf

server {
      listen       443 ssl;
      server_name  xiangzhangshugongyi.com;

      ssl_certificate      cert/214487958220243.pem;
      ssl_certificate_key  cert/214487958220243.key;

      ssl_session_cache    shared:SSL:1m;
      ssl_session_timeout  5m;

      ssl_ciphers  HIGH:!aNULL:!MD5;
      ssl_prefer_server_ciphers  on;

      location / {
          proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
          proxy_set_header Host $http_host;
          proxy_set_header X-Forwarded-Proto https;
          proxy_redirect off;
          proxy_connect_timeout      240;
          proxy_send_timeout         240;
          proxy_read_timeout         240;
          # note, there is not SSL here! plain HTTP is used
          proxy_pass http://127.0.0.1:8080;
      }
  }

③ 重启 nginx,通过 证书绑定域名进行 https 访问到 服务器跑在 8080 的服务
通过https访问


转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 jaytp@qq.com

×

喜欢就点赞,疼爱就打赏