Skip to content

Instantly share code, notes, and snippets.

@geolaw
Created March 1, 2022 21:20
Show Gist options
  • Save geolaw/2dbd9f95986cba67d003da21468ce765 to your computer and use it in GitHub Desktop.
Save geolaw/2dbd9f95986cba67d003da21468ce765 to your computer and use it in GitHub Desktop.
Simple systemd unit file for python http server
[Unit]
Description=http redirect
# simple web service to server a index.html with a meta refresh without having to do via apache/nginx
[Install]
WantedBy=multi-user.target
[Service]
Type=simple
User=root # need root to bind to port 80
WorkingDirectory=/Downloads/html/ # directory containing a index.html with a meta refresh for redirect
ExecStart=python -m http.server 80
StandardOutput=null # log nothing
StandardError=null # log nothing
@geolaw
Copy link
Author

geolaw commented Mar 1, 2022

I recently moved my home docker containers around and off what has been traditionally my primary server, which has now become my hypervisor running kvm with everything else disabled. Instead of using apache or nginx, I just wanted a simple, single thread to redirect traffic over to my new server - running a single python thread

@geolaw
Copy link
Author

geolaw commented Mar 1, 2022

$ cat /Downloads/html/index.html

<html>
<meta http-equiv="refresh" content="0;URL='http://192.168.29.7'"/>
</html>

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment