วันจันทร์, พฤษภาคม 30, 2559

Fixed cannot access Tomcat port 8080 on AWS

Just a quick blog notes after try to deploy a demo spring-boot project on Tomcat 8 on EC2 instance (AWS)


Tomcat homepage inaccessible 


i.e. Host not found ... http://ec2-xx-yy-218-150.ap-southeast-1.compute.amazonaws.com:8080/

After execute Tomcat you might found that it cannot access via the browser; This is might because of your networks did not support IPv6 yet. So, We will do force the Tomcat to operate with IPv4 only.

Solution

- Shutdown the Tomcat

- Edit catalina.sh

Add java options JAVA_OPTS. See the code below:

...
#
#   LOGGING_MANAGER (Optional) Override Tomcat's logging manager
#                   Example (all one line)
#                   LOGGING_MANAGER="-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager"
# --------------------------------------------------------------------

JAVA_OPTS=" -Djava.net.preferIPv4Stack=true "

# OS specific support.  $var _must_ be set to either true or false.
cygwin=false

darwin=false
...

- Startup Tomcat; It should be accessible now ;)


Command to check if Tomcat running(binding) with IPv6 

$ netstat -ant
...
tcp6       0      0 :::8080                   :::*                    LISTEN
...

After catalina.sh modification 

$ netstat -ant
...
tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN
...





ไม่มีความคิดเห็น :