[請益] Nginx 同主機多伺服器配靜態資源

看板MIS作者 (搖滾少女!! 活力棉花糖!!)時間1年前 (2023/03/05 18:53), 1年前編輯推噓0(003)
留言3則, 2人參與, 1年前最新討論串1/1
同台電腦配置多個伺服器 類似這樣 location /server3 { proxy_pass http://127.0.0.1:7000/; } location /server2 { proxy_pass http://127.0.0.1:8000/; } location / { proxy_pass http://127.0.0.1:9000/; } 如果打開 server3 http://localhost/server3 其中有引入靜態資源路徑是 ./index.css 找的會是根伺服器 localhost / 的靜態資源 要用 localhost:7000/index.css 才能正確讀到 請問我要怎麼配置 才能即使 根伺服器 和 server3 都有引用 ./index.css 也能正確分別引用 使用 http://localhost/server3 能正確讀取到 ./index.css 而不是404或其他伺服器的 -- ※ 發信站: 批踢踢實業坊(ptt.cc), 來自: 111.243.150.14 (臺灣) ※ 文章網址: https://www.ptt.cc/bbs/MIS/M.1678013600.A.8A6.html ※ 編輯: surimodo (111.243.150.14 臺灣), 03/05/2023 18:54:58

03/05 19:32, 1年前 , 1F
rewrite
03/05 19:32, 1F

03/05 19:35, 1年前 , 2F
rewrite ^/server3/(.*) /$1 break; 試試
03/05 19:35, 2F

03/06 08:01, 1年前 , 3F
後來小改伺服器專案 url加前綴區分
03/06 08:01, 3F
文章代碼(AID): #1a17IWYc (MIS)