Another way of achieving the same thing is to add an iptable redirection rule.
We have done it this way, because we didn’t want to add the xinit package to our standard configuration.
These instructions were created on a Debian Lenny system.
Create a new “if-up” script:
sudo vim /etc/network/if-up.d/jira-redirect
Make this its content:
#!/bin/bash
for i in $(sudo ifconfig | grep ‘inet addr:’| grep -v ‘127.0.0.1’ | cut -d: -f2 | awk ‘{ print $1}’); do
sudo iptables -t nat -I PREROUTING 1 -d $i -p tcp –dport 80 -j DNAT –to $i:8080
sudo iptables -t nat -I PREROUTING 1 -d $i -p tcp –dport 443 -j DNAT –to $i:8443
done
This script will take all the IPs the server is using as shown by ifconfig, and will add the redirect rules for them.
Make the script executable:
sudo chmod +x /etc/network/if-up.d/jira-redirect
Create a new “if-down” script:
sudo vim /etc/network/if-down.d/jira-redirect-clearer
Make this its content:
#!/bin/bash
sudo iptables -F -t nat
This script will clear all the NAT rules by using the flush (-F) directive, when the networking is restarted.
Adding this “if-down” script better handles cases where you changed a networking setting and the old ones are still there until a reboot. however as this does clear ALL of the NAT settings, make sure this doesn’t affect other things on your setup.
Make the script executable:
sudo chmod +x /etc/network/if-down.d/jira-redirect-clearer
Restart the networking service for the changes to take affect:
sudo /etc/init.d/networking restart
Recent Comments