[英]How do i use NGINX to reverse proxy to local react app
我正在嘗試使用 nginx 對我的本地 react 應用程序進行簡單的反向代理。 我無法理解這是如何工作的。 我需要location /test
的根變量還是別名? 因為 nginx 正在查找錯誤的地址。 (我在 localhost:3001 本地運行我的 React 應用程序)
已經嘗試在 "location /test" rewrite /test(.*) /$1 break
使用rewrite /test(.*) /$1 break
這是我的 nginx.conf:
server {
listen 81 ;
server_name app1.localhost;
location / {
root html;
index index.html index.htm;
}
location /test {
proxy_pass http://localhost:3001;
}
}
只需使用兩個server
塊:
server {
listen 81 default_server;
location / {
root html;
index index.html index.htm;
}
}
server {
listen 81;
server_name app1.localhost;
location / {
proxy_pass http://localhost:3001;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.