docker run -d --name busybox-http -p 8080:8080 -e TZ=UTC-8 busybox sh -c "
echo GMT-8 > /etc/TZ
mkdir -p /root/cgi-bin
cat > /root/cgi-bin/a.html <<EOF
#!/bin/sh
echo -e 'Content-Type: text/plain\n'
echo "hostname=[\$(hostname)], time=[\$(date '+%F %T')], query=[\${QUERY_STRING}], path=[\${PATH_INFO}]"
echo "requestUrl=[\${REQUEST_URI}]"
echo -e "\n=== env list:\n\$(env|sed 's/\n/
/g')"
EOF
chmod u+x /root/cgi-bin/a.html
httpd -p 8081 -h /root
cat > /root/httpd.conf <<EOF
P:/:http://localhost:8081/cgi-bin/a.html/
EOF
httpd -p 8080 -c /root/httpd.conf
sleep infinty
"
curl localhost:8080/a/b?c=1
Result Output:
hostname=[e95c54e5ff19], time=[2021-01-19 23:20:42], query=[c=1], path=[/a/b]
requestUrl=[/cgi-bin/a.html/a/b?c=1]
=== env list:
GATEWAY_INTERFACE=CGI/1.1
HOSTNAME=e95c54e5ff19
SHLVL=2
REMOTE_ADDR=[::ffff:127.0.0.1]
HOME=/root
QUERY_STRING=c=1
HTTP_USER_AGENT=curl/7.29.0
REMOTE_PORT=51456
HTTP_ACCEPT=/
SCRIPT_FILENAME=/root/cgi-bin/a.html
HTTP_HOST=localhost:8080
REQUEST_URI=/cgi-bin/a.html/a/b?c=1
SERVER_SOFTWARE=busybox httpd/1.31.1
PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin
SERVER_PROTOCOL=HTTP/1.0
PATH_INFO=/a/b
REQUEST_METHOD=GET
PWD=/root/cgi-bin
SCRIPT_NAME=/cgi-bin/a.html