Score:0

Rewrite and Cache Response URLs in reverse proxy

id flag

Currently we have a software solution which needs do call home, e.g. for auto update it needs to contact an azure container registry. We are restricted to only have outgoing connections to example.com, all other outgoing connections are blocked by the firewalls of the customers. Therefore all connections we need to operate the software have to go through our reverse proxy.

Therefore we created a reverse proxy like example.com/acr/* which does proxy the connection to example.azurecr.io. Thats all working fine. The problem I have is what do I do with the returning URLs in the answer?

For example by requesting a docker image via example.com/arc/something I get back a response like this, telling docker where the docker container blobs are stored.

HTTP/1.1 307 Temporary Redirect
Location:   https://weumanaged131.blob.core.windows.net/...e5698526-1gpll71q59//docker/registry/v2/blobs/sha256/a8/a87a....

Obviously I can't connect to this URL, because I'm restricted to example.com.

Question: Is it somehow possible to rewrite and cache the response URLs with an URL like this: example.com/acr/<UUID>(with a random UUID)? When calling this URL through the reverse proxy, the reverse proxy will proxy the URL to the original location URL like shown above. If there is another solution to redirect the response URLs through my reverse proxy, I'm happy to hear them.

Is something like this even possible with nginx? I'm not restricted to nginx, if some other solution can solve this problem.

Thank you, Philipp

Edit: To make things clear, the software solution is installed on a machine inside the customer network. The customer network only allows outgoing connections to www.example.com from this particular machine. The reverse proxy is installed on the server in our network (in this case in our Azure cloud network). Therefore it is not possible for us to call other domains from this machine.

Score:0
us flag

You need to use a forward proxy like Squid, not a reverse proxy like nginx.

Install Squid on the www.example.com server, and configure your software solution to use the forward proxy at www.example.com.

Score:0
fk flag

I am not sure I follow the whole of it, but if you have a proxy, why shouldn't everything pass by the proxy? Why doesn't a call to weumanaged131.blob.core.windows.net go via the proxy ?

Just for a test, in a linux environment, the proxy may be set for any program/service via the http_proxy and https_proxy variables. Possibly adding them at the beginning of the service script would do the trick. E.g. export http_proxy=http://proxy:port And if it requires user authentication : export http_proxy=http://username:password@proxy:port In case of docker, there are more tricks, or it may require capital letters variables: HTTP_PROXY and HTTPS_PROXY.

phiob avatar
id flag
Thanks for your answer, but I think I didn't explain something well. I edited the post to make things clear. We do not have installed a proxy in general on our servers, just a reverse proxy for calls to the specific urls.
djdomi avatar
za flag
either post the url or hide it it seems to me that azurecr.io may be the domain?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.