0

I am a very newbie in ubuntu and in computer programming in general. I would like to create a hub which receives http requests from a server and sends it to an other machine. So my question is how can I write a script in bash which detects http requests from a specific web server ?

I only know how to do GET and POST requests with command line (thanks to curl command). And I would like to not use any other softwares to write the script except in bash.

I hope you can bring me some answers, I don't even know weather it is possible to do all those things.

Thank you very much.

1
  • That is called a webserver, I think. Look at apache or any other webserver of choice. Then look how to redirect requests in that webserver.
    – Soren A
    Jul 26 '19 at 9:00
0

Not a huge bash programmer, but a Google search resulted in shinatra.sh which is a "bash web server in 5 lines". You may be able to adapt it to address your needs. I found the information here: https://github.com/benrady/shinatra

The solution uses netcat (nc) to listen on a port for a request, and then do something. Specific documentation on nc is available by typing man nc on Ubuntu at the terminal. But you can also read it online here: https://www.computerhope.com/unix/nc.htm

2
  • Thank you so much i will take the time to look at it !
    – Tuxedo
    Jul 26 '19 at 11:29
  • I think that's exactly what I was looking for, ofcourse the script will be modified to fit my requirements but the script provides a solid base to start. Thank you so much !
    – Tuxedo
    Jul 26 '19 at 12:45

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.