I'm dealing with some legacy issues where I have to reconfigure servers hosting a PHP based application. One of the decisions was to move away from Apache onto Nginx.
Now the application hosts two kinds of responses;
/some/path -> HTML templates
/api/some/path -> JSON
The application is based on Laravel. Now, I have two virtual hosts, my.app.com
and api.app.com
. What I've thought of as a decent solution is to have api.app.com
proxy the requests to my.app.com
with a /api
prepended to the request path. So;
GET api.app.com/user -> NGINX PROXY -> my.app.com/api/user
I'm no expert at Nginx configuration and this is what I think should work:
location / {
proxy_pass http://my.app.com:8888/api;
proxy_set_header X-Real-IP $remote_addr;
}
The idea is to ensure that people trying to GET from api.app.com/something
actually get a response from my.app.com/api/something
But that doesn't work. I keep getting exceptions from the app saying that the path cannot be found in the routes.
Can anyone tell me what's going on here?