Giine 发表于 2018-3-17 15:48:36

server {
        server_name gov.cn;
        listen   443 ssl http2;
        ssl_protocols TLSv1.2 TLSv1.1 TLSv1;
            ssl_certificate /etc/letsencrypt/live/gov.cn/fullchain.pem; # managed by Certbot
            ssl_certificate_key /etc/letsencrypt/live/gov.cn/privkey.pem; # managed by Certbot

      ssl_session_cache      shared:SSL:10m;
      ssl_session_timeout      60m;
      ssl_session_tickets      on;
      ssl_stapling             on;
      ssl_stapling_verify      on;
      resolver               8.8.4.4 8.8.8.8valid=300s;
      resolver_timeout         10s;

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

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

      client_max_body_size    4m;

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

        error_page 404 /404.html;
        error_page 500 502 503 504 /50x.html;
        location = /50x.html {
                root /usr/share/nginx/html;
        }
        location ~ \.php$ {
                try_files $uri /index.php =404;
                fastcgi_split_path_info ^(.+\.php)(/.+)$;
                fastcgi_pass 127.0.0.1:9000;
                fastcgi_index index.php;
                fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                include fastcgi_params;
        }

}

server {
        listen 80;
        server_name gov.cn www.gov.cn;
        location / {
                rewrite ^/(.*)$ https://gov.cn/$1 permanent;
        }
}
页: 1 [2]
查看完整版本: 如何让http自动跳转到https