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; } }
本文来自博客园,作者:MegaloBox,转载请注明原文链接:https://www.cnblogs.com/cpw6/p/14519450.html