Skip to content
Advertisement

Cannot access Tomcat via web after EC2 reboot

I rebooted my Amazon EC2 instance, and now I can’t connect to my Tomcat7 web server via the web.

Here’s what I’ve tried, to no avail:
1) Confirmed that my settings are correct in Tomcat’s server.xml file:

    <Connector port="8080" protocol="HTTP/1.1"
           connectionTimeout="20000" />
               redirectPort="8443" />

    <Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
           maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
... />

2) updated my iptables via this post:

/sbin/iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
/sbin/iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
/sbin/iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080

3) Reviewed my tomcat catalina.out log (success, no errors)

4) Tried connecting to my domain via ip. It redirects to https, but doesn’t show anything. I cannot get either of my webapps up, nor the Tomcat7 homepage.

Any help would be appreciated!

Advertisement

Answer

It looks like my iptables commands may have been off a bit. Here’s what I ran to get it to work:

/sbin/iptables -t nat -I PREROUTING -p tcp --destination-port 80 -j REDIRECT --to-ports 8080
/sbin/iptables -t nat -A OUTPUT -p tcp -d <my_ip_address,my_ip_address> --dport 80 -j  REDIRECT --to-port 8080
/sbin/iptables -t nat -I PREROUTING -p tcp --destination-port 443 -j REDIRECT --to-ports 8443
/sbin/iptables -t nat -A OUTPUT -p tcp -d <my_ip_address,my_ip_address> --dport 443 -j  REDIRECT --to-port 8443

It looks like I need to open up ports 443 and 8443 as well. I’ll leave this post up so others can refer to it if they come across the same issue.

UPDATE: I also needed to update my server.xml, changing

<Connector port="8080" protocol="HTTP/1.1"  
 connectionTimeout="20000" />  
 redirectPort="8443" /> 

to:

<Connector port="8080" protocol="HTTP/1.1"  
 connectionTimeout="20000" />  
 redirectPort="443" /> 
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement