Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Proxy for 3rd party URLs

Avatar

Level 6

Is there anyway to proxy forwarding 3rd party URLS present in CQ page ?

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

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

View solution in original post

7 Replies

Avatar

Employee Advisor

Hi,

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

kind regards,
Jörg

Avatar

Community Advisor

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

Avatar

Level 6

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

Avatar

Correct answer by
Employee Advisor

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

Avatar

Level 6

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

Avatar

Employee Advisor

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

Jörg

Avatar

Level 8

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.