nginx 同一個埠 不同路由 請求 不同 服務
阿新 • • 發佈:2022-03-08
直接上配置
user root; worker_processes 1; events { worker_connections 1024; } http { include mime.types; default_type application/octet-stream; sendfile on; keepalive_timeout 65; server { listen 80; server_name localhost; location / { proxy_pass http://localhost:50001; } location /mobile/ { proxy_pass http://localhost:50002/; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; } } server { listen 50001; location / { root /home/ifnk/proj/test-web/build; index index.html index.htm; } location /api { proxy_pass http://localhost:5005/; } } server { listen 50002; location / { root /home/ifnk/proj/web-collect-monorepo/packages/web-collect/dist; index index.html index.htm; } location /api { proxy_pass http://localhost:5005/; } } }
有空解釋和填坑……