收藏文章 楼主

nginx 配置网站域名 www 带与不带都转跳到 https://www

版块:网站建设   类型:普通   作者:小绿叶技术博客   查看:1340   回复:0   获赞:0   时间:2022-03-08 19:12:10


server {

    listen  80;

    server_name eisc.cn  www.eisc.cn;

    return 301 https://www.eisc.cn$request_uri;

# 添加不带和带 www 的都转跳的 https://www


}


server{

    listen 443 ssl;

    server_name eisc.cn;

    return 301 https://www.eisc.cn$request_uri;

# 不带www 转跳到 www https  依然需要ssl 证书


    ssl_certificate /eisc/www/ssl/eisc/eisc.pem;

    ssl_certificate_key /eisc/www/ssl/eisc/eisc.key;

    ssl_session_timeout         5m;

    ssl_protocols               TLSv1 TLSv1.1 TLSv1.2;

    ssl_ciphers                 ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;

    ssl_prefer_server_ciphers   on;



}


server{

    listen 443 ssl;

    server_name www.eisc.cn;

# www 的 https


    ssl_certificate /eisc/www/ssl/eisc/eisc.pem;

    ssl_certificate_key /eisc/www/ssl/eisc/eisc.key;

    ssl_session_timeout         5m;

    ssl_protocols               TLSv1 TLSv1.1 TLSv1.2;

    ssl_ciphers                 ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;

    ssl_prefer_server_ciphers   on;




location / {

   proxy_pass http://eisc.cn;

   index index.php index.html;

# 由于是内网服务器,需要转发到内网 docker ,docker 已经写入 /etc/hosts


#------------- 可见ip ------------#

     proxy_set_header Host $host;

     proxy_set_header X-Real-IP $remote_addr;

     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;


}


}

提供企业建站服务,免费网防系统,提交信息登录 http://yundun.ddoss.cn 邮箱: proposal@ddoss.cn 
回复列表
默认   热门   正序   倒序

回复:nginx 配置网站域名 www 带与不带都转跳到 https://www

头像

用户名:

粉丝数:

签名:

资料 关注 好友 消息