Skip to content

Instantly share code, notes, and snippets.

@yangl
Last active March 2, 2020 13:19
Show Gist options
  • Save yangl/6d9c42a417b134111178 to your computer and use it in GitHub Desktop.
Save yangl/6d9c42a417b134111178 to your computer and use it in GitHub Desktop.
nginx根据user-agent手机端跳转,nginx rewrite详见:http://seanlook.com/2015/05/17/nginx-location-rewrite/
location = / {
if ($http_user_agent ~* "(Android|iPhone|iPod|Symbian|BlackBerry|Windows Phone|Mobile|J2ME)") {
rewrite ^ http://m.uxin.com permanent;
}
#htpasswd密码生成可用在线工具http://tool.oschina.net/htpasswd,加密方式选Crypt
auth_basic_user_file /data/soft/nginx/conf/htpasswd;
auth_basic "please input passwd, or contact YANGL";
proxy_pass http://newwww;
proxy_http_version 1.1;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header Remote-Addr $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment