Skip to content

Instantly share code, notes, and snippets.

@lemenkov
Last active January 11, 2016 13:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save lemenkov/068254bba7731bd5694a to your computer and use it in GitHub Desktop.
Save lemenkov/068254bba7731bd5694a to your computer and use it in GitHub Desktop.
A simple HTTP-service systemd example
[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