Nginx多端适配

Nginx多端适配

通过nginx获取用户设备的Agent来判断

# 多端适配
server {
    listen 7000;
    server_name zhhll.icu;
    location / {
        root /Users/zhanghe/Desktop/nginx;
        # 1.如果是静态页面判断agent如果是移动端则指向移动端
        # 2.pc和m端是两个服务,可以通过proxy_pass反向代理到对应的服务
        if ($http_user_agent ~* '(Android|webOS|iPhone|iPod|BlackBerry)') {
            root /Users/zhanghe/Desktop/nginx-demo/mob;
        }
        index index.html index.htm;
    }
}

https://zhhll.icu/2023/服务器/Nginx/17.Nginx多端适配/

本文由 mdnice 多平台发布

posted @ 2023-11-04 13:38  拾光师  阅读(7)  评论(0编辑  收藏  举报  来源