nginx目錄結構html
nginx ├── conf // 配置文件 │ └── annotation // 自定義註解 ├── html // html頁面 │ └── pc // PC端 │ └── index.html //首頁 │ └── mobile // 移動端 │ └── index.html //首頁 ├── sbin // nginx 命令 │ └── nginx
訪問不一樣頁面 android
server { listen 80; server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location /{ #PC端根路徑 root html/pc; #經過user-agent判斷來源是移動端仍是PC端 if ($http_user_agent ~* "(mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)") { #移動端根路徑 root html/mobile; } # index index.html; }
訪問不一樣域名nginx
server { listen 80; server_name xxx.com; location / { proxy_pass http://localhost:3000; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; if ($http_user_agent ~* "(mobile|nokia|iphone|ipad|android|samsung|htc|blackberry)") { #判斷是否爲移動設備訪問 rewrite ^/(.*)$ http://m.xxx.com$uri redirect; # 跳轉到m.xxx.com } } }