Reputation: 5768
I'm trying to make any request that lacks a file extension be directed to my express server, apart from /
and /dashboard
, which I want to go to my connect server. /dashboard
is supposed to request /dashboard.html
from the connect server. Here's what I have:
server {
listen 80;
server_name myserver;
index index.html;
location @connect {
proxy_pass http://localhost:9001;
}
location @express {
proxy_pass http://localhost:9002;
}
location ~* \.(html|js|css|png|jpg|jpeg|gif|ico)$ {
try_files $uri @connect;
expires 7d;
}
location = / {
try_files $uri @connect;
}
location = /dashboard {
try_files $uri.html @connect;
}
location / {
try_files $uri @express;
}
}
/
goes to the connect server as intended, but /dashboard
goes to my express server. Can anyone help me understand what I'm doing wrong?
Upvotes: 1
Views: 339
Reputation: 15110
The solution is to replace:
location = /dashboard {
try_files $uri.html @connect;
}
with
location = /dashboard {
proxy_pass http://localhost:9001/dashboard.html;
}
Reference:
Upvotes: 2
Reputation: 42799
I think the issue is because you used location = /dashboard
and i believe that this for example won't match /dashboard/
, do u want only the exact location to match? i mean why not use location /dashboard/
( removing the =
)
Upvotes: 0