Last active
January 11, 2016 13:36
-
-
Save lemenkov/068254bba7731bd5694a to your computer and use it in GitHub Desktop.
A simple HTTP-service systemd example
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=Enable HTTP access to the repository | |
After=syslog.target network.target | |
[Service] | |
Type=simple | |
# Execute ExecStartPre and ExecStopPost directives from superuser | |
PermissionsStartOnly=true | |
User=ftp | |
Group=ftp | |
WorkingDirectory=/var/ftp/pub | |
# Setup redirection from port 80 to port 8000 | |
ExecStartPre=/sbin/iptables -t nat -A PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000 | |
ExecStart=/usr/bin/python -m SimpleHTTPServer 8000 | |
# Cleanup redirection listed above | |
ExecStopPost=/sbin/iptables -t nat -D PREROUTING -p tcp --dport 80 -j REDIRECT --to-ports 8000 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment