Skip to content

Instantly share code, notes, and snippets.

@gibatronic
Created November 16, 2018 14:18
Show Gist options
  • Save gibatronic/e966b07d2f7c712457011de0fff7a59b to your computer and use it in GitHub Desktop.
Save gibatronic/e966b07d2f7c712457011de0fff7a59b to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
#
# Make your server get traffic from port 80 without having to run it with sudo privilege.
# Based on: Running Jenkins on Port 80 or 443 using iptables
# https://wiki.jenkins.io/display/JENKINS/Running+Jenkins+on+Port+80+or+443+using+iptables
# allow traffic on ports 80 and 8080
sudo iptables -I INPUT 1 -p tcp --dport 80 -j ACCEPT
sudo iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT
# redirect traffic from port 80 to port 8080
sudo iptables -A PREROUTING -t nat -p tcp --dport 80 -j REDIRECT --to-port 8080
# persist rules after reboot
sudo apt-get install iptables-persistent
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment