例子 項目分為前台和后台 后台有上傳圖片等功能給前台用 后台web根目錄為admin 前台web根目錄為frontend nginx 配置 server { server admin; listen 9000; root admin; location ~ .*\.(js|css|png)$ { #后台不存資源資源都保存到前台 能保證使用后台域名訪問前台的靜態資源 try_files @fronted } location @fronted { proxy_pass http://127.0.0.1:9100; } } server { server fronted; listen 9100; root fronted; location ~ .*\.(js|css|png)$ { try_files $uri =404; } }
參考連接:http://nginx.org/en/docs/http/ngx_http_core_module.html