Nginx proxy to Apache - resolve HTTP ORIGIN

Posted by Fratyr on Server Fault See other posts from Server Fault or by Fratyr
Published on 2013-11-03T13:38:06Z Indexed on 2013/11/03 15:56 UTC
Read the original article Hit count: 246

Filed under:
|
|

I have a server setup with nginx serving static content and proxy all PHP/dynamic requests to apache on 127.0.0.1

I'm building an API for my databases, and I need to allow clients by their origin (domain name), rather than just IP. Based on CORS rules.

So when I send an HTTP header header("Access-Control-Allow-Origin: www.client-requesting.myapi.com"); from my API server, I have to tell it which origin I allow, otherwise client side requests won't work to my API due to same-origin policy.

The question is how can I know which domain name (if any) called my API?

What should be the nginx and apache configuration to pass the origin parameter? I tried to google, and all I found is some possible solution with mod_rpaf, but I wanted to be sure.

Thanks!

© Server Fault or respective owner

Related posts about apache2

Related posts about nginx