nginx实现默认跳转HTTPS

最后更新于:2020-09-10 22:06:58 | 59 次浏览

server {
    listen 80;
    server_name www.hzbiz.bet;
    index index.html index.php index.htm;
    access_log  /usr/local/nginx/logs/8080-access.log main;
    error_log  /usr/local/nginx/logs/8080-error.log;

    return   301 https://server_namerequest_uri;
    //这是nginx最新支持的写法,就是这行代码可以实现80端口直接强制跳转到443也就是https

    location ~ / {
    root /var/www/html/8080;
    index index.html index.php index.htm;
    }
}