-1

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?

1

1 Answer 1

0

A tip from https://serverfault.com/a/586607:

location ~ /(?<path>.*) { proxy_pass http://my.app.com:8888/api/$path; proxy_set_header X-Real-IP $remote_addr; } 
1
  • 1
    If the question is a duplicate - please flag it as such. Commented Nov 24, 2014 at 15:59

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.