全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
12
返回列表 发新帖
楼主: 天蚕土豆

如何让http自动跳转到https

[复制链接]
发表于 2018-3-17 15:48:36 | 显示全部楼层
  1. server {
  2.         server_name gov.cn;
  3.         listen   443 ssl http2;
  4.         ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
  5.             ssl_certificate /etc/letsencrypt/live/gov.cn/fullchain.pem; # managed by Certbot
  6.             ssl_certificate_key /etc/letsencrypt/live/gov.cn/privkey.pem; # managed by Certbot

  7.         ssl_session_cache        shared:SSL:10m;
  8.         ssl_session_timeout      60m;
  9.         ssl_session_tickets      on;
  10.         ssl_stapling             on;
  11.         ssl_stapling_verify      on;
  12.         resolver                 8.8.4.4 8.8.8.8  valid=300s;
  13.         resolver_timeout         10s;

  14.         root /var/www/gov/public;
  15.         index index.html index.php index.htm;

  16.         location / {
  17.                 try_files $uri $uri/ /index.php?$args;
  18.         }

  19.         client_max_body_size    4m;

  20.         access_log /var/log/nginx/elsenow.log;
  21.         error_log /var/log/nginx/error.elsenow.log;

  22.         error_page 404 /404.html;
  23.         error_page 500 502 503 504 /50x.html;
  24.         location = /50x.html {
  25.                 root /usr/share/nginx/html;
  26.         }
  27.         location ~ \.php$ {
  28.                 try_files $uri /index.php =404;
  29.                 fastcgi_split_path_info ^(.+\.php)(/.+)$;
  30.                 fastcgi_pass 127.0.0.1:9000;
  31.                 fastcgi_index index.php;
  32.                 fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  33.                 include fastcgi_params;
  34.         }

  35. }

  36. server {
  37.         listen 80;
  38.         server_name gov.cn www.gov.cn;
  39.         location / {
  40.                 rewrite ^/(.*)$ https://gov.cn/$1 permanent;
  41.         }
  42. }
复制代码
您需要登录后才可以回帖 登录 | 注册

本版积分规则

Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2024-4-18 20:16 , Processed in 0.055427 second(s), 7 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表