Instant reverse HTTP proxy from a Linux command-line

7

1

There is a nice trick to instantly serve contents of a current working directory by HTTP locally:

$ python -m SimpleHTTPServer

This command launches HTTP server at *:8000, serving $PWD contents.

I'm looking for something similar, but for setting up a reverse-proxy.

Something like this:

$ instant-reverse-http-proxy --listen-on 'http://localhost:8000/' --proxy-to 'https://example.com/path'`

So that

$ GET http://localhost:8000/bar

would fetch https://example.com/path/bar.

Any clues?

Alexander Gladysh

Posted 2012-01-07T22:12:47.500

Reputation: 792

Answers

7

socat?

# socat TCP-LISTEN:80,reuseaddr,fork,su=nobody TCP:www.dmz.mydomain.org:80

(from lorgor.blogspot and MIT)

# socat -vv OPENSSL-LISTEN:443,cert=cert.pem,cafile=cacert.pem, \
cert=cert.key,reuseaddr,fork TCP4:192.168.34.65:80

(from https://www.buntschu.net/blog/?p=242)

RedGrittyBrick

Posted 2012-01-07T22:12:47.500

Reputation: 70 632

1The last link is dead, please correct for future comers – Ahmed Essam – 2017-12-19T15:56:30.170

0

Theres a node module for that: https://github.com/cha0s/kiss-proxy. Supports command line arguments and a config file for more complex situations.

Only downside with kiss-proxy is that it looks slightly dated and may not run on newer versions of node.

Dane Macaulay

Posted 2012-01-07T22:12:47.500

Reputation: 101

1could you give more detail than a link ? – Archemar – 2015-11-18T09:06:17.907