nginx常见配置之SSL证书配置以及多条件判断

SSL证书配置

server {
        listen       80;
        listen       443 ssl;
        server_name  www.linux66.cn;
        root         /data/www/;
        index        index.html;

        ssl_certificate      /usr/share/nginx/cert/www_linux66_cn_bundle.crt;
        ssl_certificate_key  /usr/share/nginx/cert/www_linux66_cn.key;
        ssl_session_timeout 5m;
        ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
        ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
        ssl_prefer_server_ciphers on;
        charset utf-8;

        set $is_mobile no;
        if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|mobile.+firefox|netfront|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0|symbian|treo|up\.(browser|link)|vodafone|wap|windows ce|xda|xiino") {
           set $is_mobile yes;
        }

        location / {
           if ($is_mobile = yes) {
                   
           }
        }
}

1、403转404

2、指定404页面地址

error_page 403  =404 /404.html;
error_page 404 /404.html;

不包含匹配前缀302跳转到首页

location / {
      if ($request_uri ~ "^/(huishou|buy|chaxun|chongzhi|card|news|help|member|tag|goumai|callcord|ehopcard|foodcord|gamecord|info|oilcard|que|sug|use|videocord|wenti|zixun|cardfor)") {
	         set $flag "1";
      }
      if ($request_uri = /) {
                 set $flag "1";
       }
						
      if ( $flag != "1" ) { 
                 return 302 http://www.linux66.cn/;
      }
}

访问/index.html永久(301)重定向到根

if ($request_uri = /index.html) {
     return 301 https://www.linux66.cn/;
}
暂无评论

发送评论 编辑评论

|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇