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)
httprequest can be intercepted by a proxy for example. For
httpsyou 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.
varnishhave URL mangling functions and can cache results for other systems.
example.orgetc, or sub-domains of these) instead. These
example.*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
.exampleTLD, such as