0

I would like to quickly run a simple server locally which can receive an HTTP request, forward it to another http address, and return the response from that other address. I've been trying to figure out if this could be done with a 1-liner with netcat, but to no avail so far. Is there any one-liner way of doing this short of writing a script for it?

To be clear, I know I could do it by writing a small python/bash/ruby/etc script, but I'm wondering if the native command line utilities can handle such a simple use case.

3
  • Writing an http proxy (which is what your Q is describing) is not a trivial task you could do with a 1-liner, or even with a 100 lines bash script. That's not a "simple use case" (Even ignoring the case where the server redirects any http to https, as most do in 2019). – mosvy Dec 27 '19 at 2:29
  • 1
    @mosvy is correct, your best bet here is to get a real HTTP proxy (or a web server that can do it). My personal suggestion would be tinyproxy, it's about as minimalistic and easy to use as you're likely to ever find for a working HTTP proxy. – Austin Hemmelgarn Dec 27 '19 at 2:52
  • The access to the external services have to be restricted only for user that have user/pass? – alessiosavi Dec 27 '19 at 3:27
0

Using ssh to setup port 8080 on localhost to redirect to the web interface on my epson printer on the local network.

ssh -L 8080:epson1:80 username@localhost

Now you can use the URL http://localhost:8080/ and access the printer's web interface.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.