server { ##商铺## listen ip:80; server_name *.cn.XXX.com; include allow.conf; if ($host ~* (.*).cn.XXX.com) { set $domain $1; } set $mobileRewrite "0"; if ($http_user_agent ~* "(android|bb\d+|meego).+mobile|avantgo|dolphin|dolphin-browser|bada\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|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|phone)|xda|xiino") { set $mobileRewrite "1"; } if ($http_cookie ~* "showpc"){ set $mobileRewrite "0"; } if ($mobileRewrite = "1") { rewrite ^/(.*) https://m.XXX.com/shop/$domain/$1 redirect; } #强制https rewrite ^(.*)$ https://$domain.cn.XXX.com$1 permanent; location / { proxy_cache my-cache; proxy_cache_valid 200 206 304 301 302 10d; proxy_cache_key $host$uri$is_args$args; proxy_set_header Host $host:$server_port; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; add_header Nginx-Cache $upstream_cache_status; proxy_pass http://cn.XXX.com; } #access_log /home/nginx/logs/access.log logstash_json;}
作者:dreamer_lk
链接:https://www.jianshu.com/p/0f1766d39dc0
点击查看更多内容
为 TA 点赞
评论
共同学习,写下你的评论
评论加载中...
作者其他优质文章
正在加载中
感谢您的支持,我会继续努力的~
扫码打赏,你说多少就多少
赞赏金额会直接到老师账户
支付方式
打开微信扫一扫,即可进行扫码打赏哦