nginx 配置pc和h5 两个页面


server {
    listen 80;
    listen 443 ssl;
    server_name baidu.com www.baidu.com;

    ssl_certificate ssl/www.baidu.com.pem;
    ssl_certificate_key ssl/www.baidu.com.key;

    # 设置默认 root 目录为 PC 端
    set $root_dir "/data/wwwroot/baiduvue-pc/dist/";


    # 根据设备类型设置不同的 root 目录
    if ($http_user_agent ~* (Mobi|Android|iPhone|iPad|iPod|Phone|Kindle)) {
        set $root_dir "/data/wwwroot/baiduvue-h5";
    }



    location / {
        root $root_dir;
       try_files $uri $uri/ /index.html last;
       index index.html;
    }

    location /dlyp {
       proxy_pass http://api.baidu.com;
    }

}


posted @ 2025-06-06 15:40  六月OvO  阅读(50)  评论(0)    收藏  举报