Lets stay I have a site at https://www.example.com
I want Nginx to redirect all requests to my site containing /rss/ to a server I have at the address 127.0.0.1:4003, appending /api/v1 and the whole path that was passed in the original request.
For example, a request to https://www.example.com/en/rss/blog would go to http://127.0.0.1/api/v1/en/rss/blog.
I tried with location, matching the url with regex:
location ~ ^.*\b(\/rss\/)\b.*$ {
rewrite ^.*\b(\/rss\/)\b.*$ /api/v1$1 break;
proxy_pass http://127.0.0.1:3007;
}
The redirection works, but is not appending the path, as I receive Cannot GET /api/v1/rss/ as response.
This is a problem with the regex I suppose, it should capture the whole path instead of /rss/ only; but how?
Any idea will be welcome!
location ~ .*(/rss/.*)