怎么解决tomcat服务器上80端口问题()

版权声明:learn spots ,CREAT areas https://blog.csdn.net/whalefall/article/details/85152085
  • 第一种解决办法,更改tomcat安装目录下的server.xml文件,

百度上都是这样说的,很多人这样都解决问题了,但是没能解决我的问题

https://stackoverflow.com/questions/4756039/how-to-change-the-port-of-tomcat-from-8080-to-80

. Edit server.xml and change port="8080" to "80"

sudo vi /var/lib/tomcat7/conf/server.xml

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

  • 第二种方法,在谷歌上查到的(成功解决问题)

https://www.locked.de/how-to-run-tomcat-on-port-80/

How to run Tomcat on Port 80

A standard Tomcat installation starts the webserver on port 8080 – which is usually not the desired behavior. In order to change the server to port 80 there are two options which I outline in the following:

Recommended: redirect traffic to 8080

Tomcat continues to listen on port 8080 (and 8443 for https). The traffic is redirected by iptables.
You don’t need to change anything in Tomcat itself, just add according Iptables-Forwarding rules. Actually this looks more complicated than the alternative – but it is the more secure way and you do not need to touch Tomcat’s config.

1

2

3

4

5

扫描二维码关注公众号,回复: 4784793 查看本文章

6

7

8

9

10

11

12

13

14

15

16

17

18

# check that rules are not there already

sudo iptables -L -n -t nat

# Add rules

sudo iptables -t nat -I PREROUTING -p tcp --dport 80  -j REDIRECT --to-port 8080

sudo iptables -t nat -I PREROUTING -p tcp --dport 443 -j REDIRECT --to-port 8443

# Check

sudo iptables -L -n -t nat

# Save

sudo /service iptables save

# Restart iptables

sudo /etc/init.diptables restart

# final check

sudo iptables -L -n -t nat

Option2: run Tomcat directly on port 80

This configures to run Tomcat directly on port 80. As this is a priviledged port, Tomcat must run as root – this is usually not recommended.
The advantage: It’s simple!
The disadvantage: A webserver shouldn’t run as root.If you want to do this nevertheless, edit /etc/tomcat7/server.xml and change the connector port from 8080 to just 80:

1

2

3

4

&lt;Connector port="&lt;del&gt;80&lt;/del&gt;80"  

   protocol="HTTP/1.1"

   connectionTimeout="20000"

   redirectPort="8443" /&gt;

Now edit /etc/tomcat7/tomcat7.conf and set the tomcat user to root:

1

TOMCAT_USER="root"

And restart Tomcat:

1

sudo service tomcat7 restart


  • 也有可能是服务器商的问题  比如:

http://www.weste.net/2017/03-16/114994.html

阿里云服务器无法访问80端口的解决办法

2017-03-16 10:57:54来源:威易网作者:小威

朋友购买了一台阿里云服务器,配置了半天就是无法从外网访问到配置的网站,IP直接访问也不行。让我帮忙看看。

朋友购买了一台阿里云服务器,配置了半天就是无法从外网访问到配置的网站,IP直接访问也不行。让我帮忙看看。

我首先检查了一下防火墙,看端口没并有被禁用。仔细检查服务器,端口也没有冲突。localhost访问是正常的,这说明只是端口被禁止访问了。后来登录阿里云管理控制台,终于找到了原因。

步骤如下:

1、登录阿里云的管理控制台。找到那台云服务器;

2、在操作的部分点击“更多”,里面藏着一个“安全组配置”;

3、进入“安全组配置”后,点击“配置规则”;

4、然后点击“公网入方向”。默认里面有22和3389端口是打开的;

5、点击右上角的“添加安全组规则”;

6、在“添加安全组规则”的对话框里面,添加“端口范围”为“80/80”,添加“授权对象”为“0.0.0.0/0”,再点击“确定”按钮。

这样在访问服务器IP,网站就正常显示了。

猜你喜欢

转载自blog.csdn.net/whalefall/article/details/85152085