`
tinyhema
  • 浏览: 150583 次
  • 性别: Icon_minigender_1
  • 来自: 杭州
社区版块
存档分类
最新评论

nginx强制https 重定向所有http请求到https

 
阅读更多
nginx重定向所有http请求到https

# vi sub.domain.conf
server{
    listen 80;

    server_name sub.domain.com;
    return 301 https://$host$request_uri;
}

server{
    charset utf-8;

    listen 443 ssl;
    ssl on;
    ssl_certificate /usr/local/nginx/conf/cert/sub.domain.com.crt;
    ssl_certificate_key /usr/local/nginx/conf/cert/sub.domain.com.key;
    server_name sub.domain.com;

    auth_basic "auth";
    auth_basic_user_file /usr/local/nginx/conf/cert/pass_file;

    access_log  /home/wwwlogs/sub.domain.com.log;
    error_log /home/wwwlogs/sub.domain.com.err;

    location / {
        proxy_pass http://127.0.0.1:99999;
    }
}
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics