Nginx配置同域名下PC端与移动端访问拦截


基于User-Agent控制

location / {
if ($http_user_agent ~* "(mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)") {
add_header X-Frame-Options SAMEORIGIN;
proxy_pass 手机端uri;
}
}

根据location+User_agent控制

 

server{
listen 4104;
server_name localhost;

location /h5/ {
if ($http_user_agent ~* "(mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)") {
add_header X-Frame-Options SAMEORIGIN;
proxy_pass http://10.24.61.41:4100;
}
}
location /gmtlogin {
proxy_pass http://10.24.61.41:4100;
}
location ^~ / {
deny all;
}
}

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM