Question

I am stuck with one issue while auto scaling. My EC2 Instance has XAMPP and tomcat, on scaling up the newly created instance does not automatically start tomcat and I even have to manually do port mapping under lampp folder using

root@domu-xx-xx-xx lampp]# /sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080

root@domu-xx-xx-xx lampp]# /sbin/iptables -t nat -I PREROUTING -p tcp --dport 8085 -j REDIRECT --to-port 91

root@domu-xx-xx-xx lampp]#/sbin/iptables-save

How can I a) Automate tomcat start up on instance creation and b) Automate above port mapping so that auto scaled instance is up & running without any manual intervention.

Any help is appreciated.

Was it helpful?

Solution

You can add all this to /etc/rc.local file to get it executed on server start-up. Create your own AMI and start your auto-scaled instanced with this AMI.

e.g.

/sbin/iptables -t nat -I PREROUTING -p tcp --dport 80 -j REDIRECT --to-port 8080
/sbin/iptables -t nat -I PREROUTING -p tcp --dport 8085 -j REDIRECT --to-port 91
/sbin/iptables-save
/path/to/tomcat/bin/startup.sh
/any/others/script.sh
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top