nginx 全站 http 跳转 https

2023-10-22 15:35:58 浏览数 (1)

代码语言:javascript复制
server {
    listen 80;
    server_name www.xxx.com;
    return 301 https://$host$request_uri;
}

server {
    listen 443;
    server_name www.xxx.com;
    ssl_certificate /etc/nginx/ssl/www.xxx.com.pem;
    ssl_certificate_key /etc/nginx/ssl/www.xxx.com.key;
    ssl on;
    root /home/www/xxx;
    location / {
        # ...
    }
}

0 人点赞