Is there a tool that'll let me programatically inspect and edit http requests being emitted from my box on the fly?
I'm hoping to create the ability to access mirrors of commonly downloaded files when the primary url is down. (Bonus points to solutions that can also work on MacOS and Windows)
More concretely, here's exactly what I'm hoping to achieve:
Process FOO on my machine attempts to make an https request to download a file some external service: https://someserver.com/fileA
The interceptor tool notices the request being made and takes over. It proceeds to make the original request to https://someserver.com/fileA
If the request is successful, the bits are returned to process FOO
But if the request fails with some error code (perhaps someserver.com is down) then the interceptor tool instead makes a request to some other url (e.g. to https://backupserver.com/fileA)
The interceptor tool returns the value returned by the backup url to process FOO
(This will primarily be running on an Ubuntu box, but I'll eventually need something similar for Windows and MacOS as well)
http
request can be intercepted by a proxy for example. Forhttps
you need to MITM yourself. Alternatively you could try to download all files from your server, from a special URL that would in turn redirect to the first available mirror.squid
orvarnish
have URL mangling functions and can cache results for other systems.example.com
(orexample.net
orexample.org
etc, or sub-domains of these) instead. Theseexample.*
domain names are reserved for use as examples and are guaranteed never to exist. Any other domain might exist (and probably does - someserver.com and backupserver.com definitely do). See Reserved Top Level DNS Names.example
TLD, such asbackupserver.example/fileA
.