Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

The solution to the inaccessibility of the browser after starting tomcat in linux

2025-02-27 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Preface

Whether you want to start or shut down the tomcat service, you have to go to the bin path under the tomcat installation directory. Of course, you don't need it if you shut down your computer.

But recently, a problem has been found after startup: Centos server, local and server ip mutual ping is normal (native ping server, server ping local), but after tomcat is deployed on the server, the local machine cannot access port 8080 of the server tomcat through the browser.

For example, the public network ip of the server is 123.123.123.123. After starting tomcat, the default port is 8080. When accessed through 123.123.123.123 tomcat 8080, the default tomcat page cannot be accessed. Consider the problem of the server firewall.

Confirm that tomcat is turned on

$ps-ef | grep tomcat

Console output, indicating that tomcat is on

Root 1428 10 Dec08? 00:02:16 / usr/local/java/jdk1.8.0_152/jre/bin/java-Djava.util.logging.config.file=/usr/local/java/tomcat8/conf/logging.properties-Djava.util.logging.manager=org.apache.juli.ClassLoaderLogManager-Djdk.tls.ephemeralDHKeySize=2048-Djava.protocol.handler.pkgs=org.apache.catalina.webresources-classpath / usr/local/java/tomcat8/bin/bootstrap.jar:/usr/local/java/tomcat8/bin/tomcat- Juli.jar-Dcatalina.base=/usr/local/java/tomcat8-Dcatalina.home=/usr/local/java/tomcat8-Djava.io.tmpdir=/usr/local/java/tomcat8/temp org.apache.catalina.startup.Bootstrap startroot 4932 4069 0 09:16 pts/0 00:00:00 grep-color=auto tomcat

If tomcat is not open, open it through tomcat's startup.sh command and enter the path where the file is located.

$/ usr/local/java/tomcat8/bin/startup.sh

Console output:

[root@izbp109iqt20o2h73tpcuvz ~] # / usr/local/java/tomcat8/bin/startup.sh Using CATALINA_BASE: / usr/local/java/tomcat8Using CATALINA_HOME: / usr/local/java/tomcat8Using CATALINA_TMPDIR: / usr/local/java/tomcat8/tempUsing JRE_HOME: / usr/local/java/jdk1.8.0_152/jreUsing CLASSPATH: / usr/local/java/tomcat8/bin/bootstrap.jar:/usr/local/java/tomcat8/bin/tomcat-juli.jarTomcat started.

Tomcat started. Indicates that tomcat has been enabled successfully!

Configure the firewall

Edit firewall configuration

$vi / etc/sysconfig/iptables

Add a firewall on port 8080 to allow access.

* filter:INPUT ACCEPT [0:0]: FORWARD ACCEPT [0:0]: OUTPUT ACCEPT [0:0]-An INPUT-m state-- state RELATED ESTABLISHED-j ACCEPT-An INPUT-p icmp-j ACCEPT-An INPUT-I lo-j ACCEPT-An INPUT-p tcp-m state-- state NEW-m tcp-- dport 22-j ACCEPT-An INPUT-m state-- state NEW-m tcp-p tcp-- dport 80-j ACCEPT-An INPUT-m state-state NEW-m tcp-p tcp-dport 3306-j ACCEPT-An INPUT-m state-state NEW-m tcp-p tcp-dport 8080-j ACCEPT-An INPUT-j REJECT -reject-with icmp-host-prohibited-A FORWARD-j REJECT-- reject-with icmp-host-prohibited

Be careful! Very critical: the configuration of the port must be at the top of the following configuration, but not below.

-An INPUT-j REJECT-- reject-with icmp-host-prohibited-A FORWARD-j REJECT-- reject-with icmp-host-prohibited

Enter I to start editing, ESC to end editing, WQ to save and exit.

Restart the firewall

$service iptables restart

After that, you can visit 123.123.123.123 tomcat 8080 through a browser, and you can see the default welcome page of the browser normally.

Summary

The above is the whole content of this article, I hope that the content of this article has a certain reference and learning value for your study or work, if you have any questions, you can leave a message and exchange, thank you for your support.

Reference link: http://blog.csdn.net/itzhangdaopin/article/details/62044620

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report