Lets say I have a REST API listening on localhost on the server example.com, and I have the following proxy working in a proxy.conf file:
location / {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8080/;
}
This means I can access my API, e.g. example.com/users. However this setup has caused some conflict, so I instead need it with the location as follows:
location /api/ {
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_pass http://127.0.0.1:8080/;
}
I can correctly access the root of the API using example.com/api. However, the links it returns are in the context example.com/users etc, not example.com/api/users as I would need.
Essentially I am asking, how do I forward the request to my API with example.com/api/ instead of just example.com?