Why does the proxy_pass http://backends/;
under the location /textcat
bring me to the root of the server (localhost:8081
) and proxy_pass http://backends;
(no trailing /) brings me to (seemingly) localhost:8081/textcat
.
I am trying to host two applications running locally on the server. These two applications are running on port 8081
and 8082
. I would like to access the app at 8081
via the /textcat
location and 8082
via /ner
. I was able to do this with the configuration below. But I dont quite understand why this works?
upstream backends {
server localhost:8081; # change to the port the webapp is listening on.
}
upstream backends_NER {
server localhost:8082; # change to the port the webapp is listening on.
}
server {
listen 443 ssl;
server_name "";
...SSL Stuff...
location = /textcat {
proxy_pass http://backends/;
}
location /ner {
proxy_pass http://backends_NER/;# This seems to work because of the trailing slash. Since the http_referrer is /ner our proxy path has to have the trailing /
}
# have to redirect on a any location request, and if the referrer is /textcat do localhost:8081
location / {
if ($http_referer ~* (/textcat) ) {
proxy_pass http://localhost:8081;
}
if ($http_referer ~* (/ner) ) {
proxy_pass http://localhost:8082;
}
}
}