kms333
kms333

Reputation: 3257

Nginx - proxy pass subpaths only

I would like to proxy the subpaths of my website to another service:

http://some-web-site.com/friends/ - renders /friends/index.html

http://some-web-site.com/friends/ [not empty request path] - proxy to another service.

Currently I have the following Nginx configuration:

location /programming/ {
   (...)
   proxy_pass http://tomcat:8080/friends;
}

But unfortunately this proxies /programming/ to http://tomcat:8080/friends.

Upvotes: 1

Views: 1884

Answers (1)

Richard Smith
Richard Smith

Reputation: 49742

Use an exact match location block to extract specific URIs for special handling:

location = /programming/ {
    ...
}
location /programming/ {
    ...
    proxy_pass http://tomcat:8080/friends;
}

See this document for details.

Upvotes: 1

Related Questions