Redirect mit iptables
Posted: 2012-10-30 14:36
Hallo
ich betreibe einen Rootserver auf UBUNTU Basis auf dem zwei Java Applikationen auf einem Glassfish AppServer laufen. Zur Zeit nutze ich einen IPTABLES Redirect um die Requests auf den Port 8181 umzuleiten:
iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A OUTPUT -o lo -p tcp --dport 443 -j REDIRECT --to-port 8181
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8181
Das funktioniert, weil grundsätzliche alle SSL Requests auf 8181 landen, wo beide Applikationen wie folgt erreichbar sind:
www.erstedomain.com/application1
www.zweitedomain.com/application2
Leider geht es auch umgekehrt, was nicht so elegant ist:
www.erstedomain.com/application2
www.zweitedomain.com/application1
Deshalb würde ich gerne folgendes Szenario implementieren und könnte damit auch eine bessere Performance bekommen, wenn ich jede Applikation in eine eigene Glassfish Domain bringe:
https://www.erstedomain.com > Redirect auf Port 8181
https://www.zweitedomain.com > Redirect auf Port 8282
Die Performance wäre deshalb besser, weil dann jede Applikationen ihre eigene JVM hat.
Kann man das mit IPTABLES implementieren?
ich betreibe einen Rootserver auf UBUNTU Basis auf dem zwei Java Applikationen auf einem Glassfish AppServer laufen. Zur Zeit nutze ich einen IPTABLES Redirect um die Requests auf den Port 8181 umzuleiten:
iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 8080
iptables -t nat -A OUTPUT -o lo -p tcp --dport 443 -j REDIRECT --to-port 8181
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 80 -j REDIRECT --to-ports 8080
iptables -t nat -A PREROUTING -p tcp -m tcp --dport 443 -j REDIRECT --to-ports 8181
Das funktioniert, weil grundsätzliche alle SSL Requests auf 8181 landen, wo beide Applikationen wie folgt erreichbar sind:
www.erstedomain.com/application1
www.zweitedomain.com/application2
Leider geht es auch umgekehrt, was nicht so elegant ist:
www.erstedomain.com/application2
www.zweitedomain.com/application1
Deshalb würde ich gerne folgendes Szenario implementieren und könnte damit auch eine bessere Performance bekommen, wenn ich jede Applikation in eine eigene Glassfish Domain bringe:
https://www.erstedomain.com > Redirect auf Port 8181
https://www.zweitedomain.com > Redirect auf Port 8282
Die Performance wäre deshalb besser, weil dann jede Applikationen ihre eigene JVM hat.
Kann man das mit IPTABLES implementieren?