我正在嘗試在 nginx conf 中實作類似的東西:
子域
- sub.domain.com -> 提供 html
- sub.domain.com/api -> 代理到埠 3001
- sub.domain.com/viewer -> 提供另一個 html
子域2
- sub2.domain.com -> 代理到埠 3000
唯一不起作用的路線是viewer,我從“location /”獲取html。所有其他配置都運行良好。
我試圖將查看器移動到底部,然后移動到頂部和中間,無論它不起作用。
我使用 CentOS7。這是服務器中當前的配置:
events {
}
http {
server {
listen 80;
listen [::]:80;
server_name www.sub.domain.com subdomain.com;
location /viewer {
root /opt/viewer/;
try_files $uri /index.html;
index index.html;
}
location / {
root /opt/client-bo/;
try_files $uri /index.html;
index index.html;
}
location /api {
proxy_pass "http://localhost:3001";
}
}
server {
listen 80;
server_name www.sub2.domain.com sub2.domain.com;
listen [::]:80;
location / {
proxy_pass "http://localhost:3000";
}
}
}
謝謝!
uj5u.com熱心網友回復:
如果您的查看器應用程式位于該/opt/viewer目錄中,你希望它是下可用的/viewerURI前綴,你應該使用root /opt;的location /viewer { ... }。檢查root和alias指令之間的區別。
接下來,try_files指令的最后一個引數被視為要重新評估的新 URI,因此您將/index.html被視為將與location / { ... }. 您應該將該指令更改為
try_files $uri /viewer/index.html;
轉載請註明出處,本文鏈接:https://www.uj5u.com/yidong/352571.html
上一篇:具有動態筆劃的SVG儀表
