我正在尝试配置nginx以同时服务于前端和后端路由。所有操作都通过使用docker完成。这是我的Nginx配置:
constructor(props) {
super(props);
...
this.tm = 0;
}
timerInterval = () => {
this.tm = setInterval(() => {
...
}, 1000);
}
问题是,当我在前面使用请求时,以clearInterval(this.tm);
开头的路由会对其进行重写,但没有保留upstream client {
server client:3000;
}
upstream api {
server api:3001;
}
server {
listen 80;
location / {
proxy_pass http://client;
}
location /sockjs-node {
proxy_pass http://client;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
}
location /auth/ {
rewrite /auth/(.*) /$1 break;
proxy_pass http://api;
}
}
部分,因此它正在寻找/api
。我该如何保存/api
部分?