I was wondering how to define server value in upstream to directory path instead of subdomain or port…
for example this won't work :
upstream backend {
server backend1.example.com/**dir/** ;
server backend2.example.com:8080;
}
server {
location / {
proxy_pass http://backend;
}
}
Does anyone have a clue how could i do this?
Best regards.
Best Answer
Normally Nginx won't modify the request parameters, including
get
string. If you want to modify it before sending to the backend, you should use rewrite.For example:
This will prepend
/somedir/
to every request for that location. Actual URL in browser won't be modified, just the request sent to the backend.