Created
March 1, 2022 21:20
-
-
Save geolaw/2dbd9f95986cba67d003da21468ce765 to your computer and use it in GitHub Desktop.
Simple systemd unit file for python http server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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 |
$ 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
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