Proxy for 3rd party URLs | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by joerghoh

Ok, you're doing some AJAX requests, which should reach out for external servers; but instead you want them to be requested from AEM and AEM should act as a proxy to those external servers. Is that correct?

No, I am not aware of any default proxy components you could use. It's a quite specific usecase and it is very hard to implement it in a general way, as you always have the risk to create an open proxy. You could implement a rule on the loadbalancer or a HTTP webserver (like Apache httpd) to forward these requests directly to the other servers instead of AEM.

My question would be, why these 3rd party requests should be made to AEM instead of the other servers directly.

Kind regards,
Jörg

7 replies

joerghoh
Adobe Employee
Adobe Employee
October 16, 2015

Hi,

can you please elaborate a bit? What do you want AEM to do?

kind regards,
Jörg

Runal_Trivedi
Level 6
October 16, 2015

Well this is how we achieved it.

We created reverse proxy on our apache webserver, below is what we configured for external REST calls:

RewriteRule ^/proxyextserv/(.*)$ http://127.0.0.1:8080/ext/application/$1 [P,QSA]
ProxyPass /proxyextserv/ http://127.0.0.1:8080/ext/application/
ProxyPassReverse /proxyextserv/ http://127.0.0.1:8080/ext/application/

Doing so, now the pattern to call external application from ajax calls remains same in JS which is /proxyextserv/param1/param2 which gets rewritten at apache to following external call http://127.0.0.1:8080/ext/application/param1/param2

- Runal

selvaganesh
Level 5
October 16, 2015

We have some ajax calls from Javascript present in AEM. I want the ajax URLs(external server) to be relative and still work inside AEM

joerghoh
Adobe Employee
joerghohAdobe EmployeeAccepted solution
Adobe Employee
October 16, 2015

Ok, you're doing some AJAX requests, which should reach out for external servers; but instead you want them to be requested from AEM and AEM should act as a proxy to those external servers. Is that correct?

No, I am not aware of any default proxy components you could use. It's a quite specific usecase and it is very hard to implement it in a general way, as you always have the risk to create an open proxy. You could implement a rule on the loadbalancer or a HTTP webserver (like Apache httpd) to forward these requests directly to the other servers instead of AEM.

My question would be, why these 3rd party requests should be made to AEM instead of the other servers directly.

Kind regards,
Jörg

selvaganesh
Level 5
October 16, 2015

The problem is we don't want to hard code the external server host and port in the html. Calls will be made from AEM page. This is for  the author so that the page will show the data from ajax calls

joerghoh
Adobe Employee
Adobe Employee
October 16, 2015

In that case I would recommend to use either the loadbalancer (assuming it has L7 capabilities) or the webserver as a proxy.

Jörg

Level 8
October 16, 2015

So is your concern hard coding or what happens at runtime? If your concern is hard coding then in addition to Jörg's suggestion of using an load balancer or a web server as the proxy you could also manage the host and port names in AEM (either as an author managed value or as an OSGI configuration). Then you make sure you feed the hostname and port number into your JavaScript functions from the AEM page when they are called an you don't have to hard code anything.