Nginx 强制 HTTPS 配置

Nginx 强制 HTTPS 配置

server {
            listen 443 ssl;
            server_name example.com;
            ssl_certificate     /cert/example.com.pem;
            ssl_certificate_key /cert/example.com.key;

            access_log  off;
            location / {
                proxy_redirect     off;
                proxy_set_header   Host             $host;
                proxy_set_header   X-Real-IP        $remote_addr;
                proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
                proxy_pass http://localhost:5000;
            }
}

server {
            listen 80;
            server_name example.com;
            return 301 https://$server_name$request_uri;
}

注意:需要将 server_name、proxy_pass、ssl_certificate、ssl_certificate_key 改为自己的值。

Nginx 强制 HTTPS 配置

上一篇:4-10 路由 URL 和参数(2)


下一篇:php 存储对象oss上传遇到的空间名称bucket(存储二级文件夹下)