0

I want to create a mapping such that, if a request comes in with a path some-path gets appended to the proxy_pass URL. For example as shown below:

location /hi/[some-path] {
    proxy_pass https://mywebsite.com/[some-path]
}

Is there a way to do this? Is that possible?

Incoming Request:
   https://foo.bar/hi/some-path/1/2/3

Proxy Passed To:
   https://mywebsite.com/some-path/1/2/3
Amanda
  • 125
  • 1
  • 6
  • You don't need the `[some-path]` bit. Anything after the `/hi/` is automatically added after the `/` in the `proxy_pass` statement. See [this document](http://nginx.org/en/docs/http/ngx_http_proxy_module.html#proxy_pass) for details. – Richard Smith Sep 17 '20 at 15:23
  • @RichardSmith Should my `proxy_pass` statement then just be `proxy_pass https://mywebsite.com/`? – Amanda Sep 18 '20 at 04:23
  • 1
    Yes, `location /hi/ { proxy_pass https://mywebsite.com/; }` will perform the transformation in your question. – Richard Smith Sep 18 '20 at 08:35

0 Answers0