搭建一个 https 网站

2019-11-01  本文已影响0人  风之化身呀
server {
   listen 443 ssl;
   server_name ycfeng.site www.ycfeng.site;
   root /root/frontend/manager;

  location / {
    index index.html index.htm;
    if (!-e $request_filename) {
      rewrite ^/(.*) /index.html last;
      break;
    }
  }

  location /api/ {
    proxy_pass http://112.33.22.155:9000/;
  }

  # https 配置相关

  location ^~ /.well-known/acme-challenge/ {
     default_type "text/plain";
     root     /root/frontend/manager/;
  }

  location = /.well-known/acme-challenge/ {
     return 404;
  }

   ssl_certificate      /etc/letsencrypt/live/ycfeng.site/fullchain.pem;
   ssl_certificate_key  /etc/letsencrypt/live/ycfeng.site/privkey.pem;
}
# 强制 http 访问 https
server {
  listen 80;
  server_name ycfeng.site www.ycfeng.site;
  return 301 https://$server_name$request_uri;
}

HTTPS 简介及使用官方工具 Certbot 配置 Let’s Encrypt SSL 安全证书详细教程

上一篇下一篇

猜你喜欢

热点阅读