
我有兩個執行 React (http://localhost:90) 和 nextjs (my-next-app.com / http://localhost:85) 應用程式的 docker 容器,而我的 Nginx 設定類似於以下內容
server {
listen 443 ssl http2;
ssl on;
ssl_certificate /foo.crt;
ssl_certificate_key /foo.key;
server_name www.my-next-app.com my-next-app.com;
location / {
...
proxy_pass http://localhost:85;
}
}
當我點擊這個按鈕時我正在嘗試做什麼www.my-next-app.com/faq,我希望用戶看到我的 React 應用程式的常見問題頁面(http://localhost:90/faq)
server {
listen 443 ssl http2;
ssl on;
ssl_certificate /foo.crt;
ssl_certificate_key /foo.key;
server_name www.my-next-app.com my-next-app.com;
location / {
...
proxy_pass http://localhost:85;
}
location /faq {
...
proxy_pass http://localhost:90/faq/;
}
}
我嘗試了上述配置,但它不起作用,我只是想知道這是否可行,並且非常感謝一些指導。我在瀏覽器控制台上得到以下輸出
Uncaught SyntaxError: Unexpected token '<' (at main~eec90089.js:1:1)
答案1
試著將 /faq/ 的 proxy_pass 放在 / 的 proxy_passs 之上