nginx配置服务器实例--支持https

42 阅读1分钟
server {
  listen 80;
  server_name site_name.com;
  root site_path;
  index index.html index.htm;
  # 把http的域名请求转成https
  return 301 https://$host$request_uri;
}

server {
  listen 443 ssl;
  server_name h5lianfu.com;

  ssl_certificate ssl_path/site_name.com.pem;
  ssl_certificate_key ssl_path/site_name.com.key;

  ssl_session_timeout 5m;
  ssl_protocols TLSv1.2 TLSv1.3;
  # 配置加密套件, 写法遵循 openssl 标准
  ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
  ssl_prefer_server_ciphers on;

  location / {
    root site_path;
    index index.html index.htm;
  }
}