Skip to content

Instantly share code, notes, and snippets.

@pkozelka
Created September 18, 2014 20:17
Show Gist options
  • Save pkozelka/fc34d2e86fb072d03896 to your computer and use it in GitHub Desktop.
Save pkozelka/fc34d2e86fb072d03896 to your computer and use it in GitHub Desktop.
Simple Redirecting Webserver in a bash script

Purpose

I need to have very simple, lightweight service that always redirects to another URL. No request parsing is needed so there should be no security risk.

Resources

The server implementation

echo "HTTP/1.1 302 Found"
echo "Location: http://www.example.com"
echo
echo

Registering the service in inetd

service myredir
{
        disable = no
        port            = 80
        flags           = IPv6
        socket_type     = stream
        wait            = no
        user            = root
        server          = /root/myredir.sh
        server_args     = --daemon
        log_on_failure  += USERID
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment