Run tomcat on port 80 not 8080

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

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

<Connector port="<del>80</del>80"

   protocol="HTTP/1.1"

   connectionTimeout="20000"

   redirectPort="8443" />

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

REF:

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

原文地址:https://www.cnblogs.com/emanlee/p/10086946.html

时间: 2024-11-09 00:12:54

Run tomcat on port 80 not 8080的相关文章

关于设置tomcat端口为80的事

今天有人要求tomcat服务器的访问地址不能带端口访问, 也就是说只能用80端口访问网站. 那么问题来了, Ubuntu系统禁止root用户以外的用户访问1024以下的商品, 因此tomcat 默认为8080也是有原因的. 因此,多才多艺的网友提供了普遍的两种方案: 1, 修改conf/server.xml中connector的port为80, 使用root用户运行tomcat.完美解决问题(ubuntu系统) windows亦是修改conf/server.xml中的connector的port

配置Tomcat监听80端口, 配置Tomcat虚拟主机,Tomcat日志

配置Tomcat监听80端口 编辑配置文件vim /usr/local/tomcat/conf/server.xml在里面找到8080<Connector port="8080" protocol="HTTP/1.1"connectionTimeout="20000"redirectPort="8443" />将里面的8080改为80,然后保存退出.然后先关闭tomcat/usr/local/tomcat/bin/

配置tomcat监听80端口,配置tomcat的虚拟主机

配置tomcat监听80端口 更改配置文件 vim /usr/local/tomcat/conf/server.xml Connector port="8080" protocol="HTTP/1.1" 修改为Connector port="80" protocol="HTTP/1.1" 查看监听端口,如果端口被占用,需要停掉nginx,如果是实际的生产环境,就不要随便停掉nginx了.肯定会影响你的线上业务的. 这时候你就可

How to run Tomcat without root privileges? 常规用户使用tomcat的80端口

How to run Tomcat without root privileges? 1. The best way is to use jsvc, available as part of the commons-daemon project. 2. One way is to put Apache httpd with mod_jk before your Tomcat servers, and use ports >=1024 in the Tomcat(s). However, if h

tomcat外网无法访问80和8080端口,其他端口可以访问

tomcat外网无法访问80和8080端口,其他端口都可以访问,很明显地看出这是运营商的问题,他们把80和8080端口对外访问屏蔽了. 解释:这两个端口是常用的HTTP协议端口,目的是防止未备案的网站对外发布. 解决办法:修改tomcat端口号或申请一个已经备案的域名指向该服务器并且向运营商要求开通.

16.4 配置Tomcat监听80端口;16.5、16.6、16.7配置Tomcat的虚拟主机(上中下);16.8 Tomcat日志

扩展: 邱李的tomcat文档 https://www.linuser.com/forum.php?mod=forumdisplay&fid=37 JAR.WAR包区别 http://blog.csdn.net/lishehe/article/details/41607725 tomcat常见配置汇总 http://blog.sina.com.cn/s/blog_4ab26bdd0100gwpk.html resin安装 http://fangniuwa.blog.51cto.com/10209

解决Tomcat改为80端口被占用的问题

在修改Tomcat的conf/servel.xml中的port="8080"改为port="80",出现端口被占用. <Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" /> 解决方法: 1.netstat -ano(得到80端口号对应的PID) 2.

16.4 配置Tomcat监听80端口 16.5/16.6/16.7 配置Tomcat虚拟主机 16.8 Tomcat日志

16.4 配置Tomcat监听80端口 16.5/16.6/16.7 配置Tomcat虚拟主机 16.8 Tomcat日志 扩展 邱李的tomcat文档 https://www.linuser.com/forum.php?mod=forumdisplay&fid=37 JAR.WAR包区别 http://blog.csdn.net/lishehe/article/details/41607725 tomcat常见配置汇总 http://blog.sina.com.cn/s/blog_4ab26b

Tomcat(介绍,JDK安装,Tomcat安装,配置Tomcat监听80端口)

一.Tomcat介绍 目前有很多网站是用Java编写的,所以解析Java程序就必须有相关的软件来完成,Tomcat就是其中之一 Tomcat是Apache软件基金会,的Jakarta项目中的一个核心项目,由apache.sun和其他一些公司及个人共同开发而成,Tomcat技术先进,性能稳定而且免费,因而深受Java爱好者的喜欢,并得到部分开发商的认可,成为目前比较流行的web因公服务器. Java程序写的网站用Tomcat+jdk来运行的. tomcat是一个中间件,真正起作用的,解析java脚