66
Views
4
Comments
Server side Redirect to URL
Question

Hi, I'm developing a webpage that needs to interact with our internal Gateway. The Gateway, in turn, makes a request to an external REST API. The response from this external API contains a URL, and I need to redirect the user to this URL. The URL is only accessible if the request originates from our internal server IP, and not on the client side. How could I achieve that?

It does seems that we can't do Server-Side Redirection, it has to be in screen-flow and client side.

2019-01-07 16-04-16
Siya
 
MVP

Since the URL is only accessible if the request originates from our internal server IP, one option is to set up a reverse proxy on your internal network. This proxy would route the call on behalf of users outside your network. For example, if the API returns a URL like `www.abc.com`, you can rewrite it as `www.reverse.com` (the reverse proxy). When accessed, the reverse proxy will handle the request to the original site and return the result to the user.

2024-10-12 12-11-20
Kerollos Adel
Champion

Using an Intermediate Server (Gateway or Proxy)

Since the URL should be accessed from your internal server, you can set up an intermediate redirection mechanism. The general idea is to make your internal Gateway handle the redirection behind the scenes on the server, while the client simply interacts with a neutral page or URL.

Here’s how you can achieve it:

  1. Server-Side Processing in Gateway:

    • When the client triggers the Gateway to call the external API, the Gateway will receive the URL from the external API response.
    • Instead of directly sending this URL back to the client, the Gateway could act as a proxy and fetch the content from the URL itself.
  2. Return a Server-Accessible Link to the Client:

    • The Gateway, after retrieving the data from the external URL (internally, from the server), can respond back to the client with a server-generated link.
    • This could be a local URL hosted on your internal server, which your front-end app can safely redirect to.
UserImage.jpg
Eugene Lim

Thank you Kerollos & Siya.

We started cracking our brain. We can achieve 1. Sever-sde Processing in Gateway with a REST GET call, and then extract the content. That is not an issue.

As for 2. Return a Server-Accessible Link, how do we host the internal page? Do we just create a new screen with a empty container and I guess we have to load it with the content we've got from 1. ? And how do we handle the interaction in the content?

We thought of iframe, but iframe likely don't handle the interaction well.

2019-01-07 16-04-16
Siya
 
MVP

Assume the URL returned by your API is "www.abc.com/app/test.aspx," which is only accessible from internal IP addresses. To make this work:

  1. Install a reverse proxy (e.g., NGINX) on your internal network. Let's assume this proxy is accessible externally as "www.xyz.com."
  2. Configure NGINX to route incoming requests to "www.abc.com."
  3. After receiving the API response, replace "www.abc.com" with "www.xyz.com" in the URL, so "www.abc.com/app/test.aspx" becomes "www.xyz.com/app/test.aspx."
  4. When the external client accesses "www.xyz.com/app/test.aspx," NGINX forwards the request to "www.abc.com/app/test.aspx" from the internal network.

This ensures the client can access the URL, even though it's restricted to internal IPs, by routing through the reverse proxy.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.