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