2

I'm in the midst of building an HTML5 site with a heavy reliance on cross-domain REST API calls. To get around the issues related to CORS, I've set up reverse proxies to point to the REST APIs. Unfortunately I've run into some issues and I'm stuck, I'm not so familiar with Apache configurations.

Take a look at my site set-up here: Image of my infrastructure

Essentially my problem is this:

  • ui.site.com/api1 returns the data from api1.serv.com (which is expected)
  • ui.site.com/api2 returns the data from api1.serv.com (which is incorrect, it should be from api2.serv.com)
  • ui.site.com/api3 returns the data from api1.serv.com (also incorrect, it should be from api3.serv.com)

What's going on here? Does apache not play well with proxy calls to one server with multiple sites running on it? I can't seem to find any resources on this, or anyone with the same issues.

Code Below

Server 1: JavaScript Front-end.

# Apache Virtual Host
ProxyPreserveHost On
SSLProxyEngine On

ProxyPass /api1 https://api1.serv.com
ProxyPassReverse /api1 https://api1.serv.com

ProxyPass /api2 https://api2.serv.com
ProxyPassReverse /api2 https://api2.serv.com

... #repeat above for  api3

Server 2: The REST apps, each one is it's own site

<Virtualhost *:443>
    ServerName api1.serv.com
    ServerAlias api1.serv.com
    .... #other directives...
</VirtualHost>

<Virtualhost *:443>
    ServerName api2.serv.com
    ServerAlias api2.serv.com
    .... #other directives...
</VirtualHost>

.... #Repeat for api3.serv.com
JJ H
  • 21
  • 2

0 Answers0