📜 ⬆️ ⬇️

Web server on bash + inetd

It took me to respond to http requests from the outside and in some way to process them (connected to the express payment terminals). The first solution was on Nginx + FastCGI (PHP), which was a bit unnecessarily heavy. And here I was visited by old memories and thanks to ru_root in LiveJournal and Google, the following was done:

[root@mysql-02 /etc]# cat services | grep freecashpayment
freecashpayment 433/tcp
freecashpayment 433/udp

By this we explained to the server that the port 433 now has a service called freecashpayment

[root@mysql-02 /etc]# cat inetd.conf | grep freecashpayment
freecashpayment stream tcp nowait root /usr/home/firefly/freecashpayment.sh freecashpayment.sh

So we make listening to port 433 and respond to it with the script freecashpayment.sh
')
[root@mysql-02 /usr/home/firefly]# cat freecashpayment.sh
#!/usr/local/bin/bash
read request
while /usr/bin/true; do
read header
[ "$header" == $'\r' ] && break;
done
url="${request#GET }"
url="${url% HTTP/*}"
echo $url


As a result, in the script in the $ url variable, we have all the parameters that were sent to us in a GET request. echo gives us all that we need in response.

We are happy :)

Source: https://habr.com/ru/post/52218/


All Articles