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/

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

  1. 关于设置tomcat端口为80的事

    今天有人要求tomcat服务器的访问地址不能带端口访问, 也就是说只能用80端口访问网站. 那么问题来了, Ubuntu系统禁止root用户以外的用户访问1024以下的商品, 因此tomcat 默认为 ...

  2. 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  ...

  3. Linux Tomcat 80端口 Port 80 required by Tomcat v8.5 Server at localhost is already in use.

    Port 80 required by Tomcat v8.5 Server at localhost is already in use. The server may already be run ...

  4. tomcat 大并发报错 Maximum number of threads (200) created for connector with address null and port 80

    1.INFO: Maximum number of threads (200) created for connector with address null and port 80 说明:最大线程数 ...

  5. tomcat、Apache服务器外网无法访问80和8080端口,其他端口可以访问

    tomcat.Apache服务器外网无法访问80和8080端口,其他端口都可以访问,很明显地看出这是网络运营商的问题,他们把80和8080端口对外访问屏蔽了. 解释:这两个端口是常用的HTTP协议端口 ...

  6. 解决 Tomcat 无法绑定 80 端口的问题,以及 Tomcat 配置虚拟目录、二级域名等

    问题 今天安装完 Tomcat,安装时把 Tomcat 默认的 HTTP/1.1 Connector Port 从 8080 改为了 7080,启动 Tomcat,在浏览器中输入 Http://loc ...

  7. iis实现类似tomcat ip:port直接访问站点

    先配置host: 建站点: iis配置文件地址:C:\Windows\System32\inetsrv\config\applicationHost.config(于tomcat中的web.xml类似 ...

  8. Tomcat介绍、安装jdk、安装Tomcat、配置Tomcat监听80端口

    1.Tomcat介绍 2.安装jdk下载:wget -c http://download.oracle.com/otn-pub/java/jdk/10.0.1+10/fb4372174a714e6b8 ...

  9. 配置Tomcat监听80端口、配置Tomcat虚拟主机、Tomcat日志

    6月27日任务 16.4 配置Tomcat监听80端口16.5/16.6/16.7 配置Tomcat虚拟主机16.8 Tomcat日志扩展邱李的tomcat文档 https://www.linuser ...

随机推荐

  1. Rpgmakermv(34) Mog_Event Sensor

    原文: =============================================================================+++ MOG - Event Sen ...

  2. hdu4746莫比乌斯反演+分块

    http://blog.csdn.net/mowayao/article/details/38875021 题意: 5000组样例. 问你[1,n] 和 [1,m]中有多少对数的GCD的素因子个数小于 ...

  3. tomcat的JVM调优

    1.error场景 Tomcat 长期运行过程遇到Caused by: java.lang.OutOfMemoryError: PermGen space或java.lang.OutOfMemoryE ...

  4. .net 常见异常及其翻译

    System.Exception//所有异常的基类型 System.ApplicationException//发生非致命应用程序错误时引发的异常 System.SystemException//为S ...

  5. 把本地windows系统上的mysql数据库移到linux系统服务器上,mysql数据库拒绝访问

    Mysql连接报错 原因是:远程服务器不允许你的其他程序访问它的数据库.所以,我们要对远程服务器进行设置,使它允许你进行连接. 步骤:一.进入mysql客户端,输入:use mysql; 二.输入:s ...

  6. Redis性能监控

    参考地址: redis教程:http://www.runoob.com/redis/redis-tutorial.html redis百度百科:https://baike.baidu.com/item ...

  7. vue之vue-cookies安装和使用说明

    vue之vue-cookies安装和使用说明npm官方链接:https://www.npmjs.com/package/vue-cookies 安装,在对应项目根目录下执行:npm install v ...

  8. Unable to open socket file: target process not responding or HotSpot VM not loaded

    Unable to open socket file: target process not responding or HotSpot VM not loaded The -F option can ...

  9. Installing Android Studio

    To set up Android Studio on Windows: Launch the .exe file you just downloaded. Follow the setup wiza ...

  10. [转载]web安全之token

    参考:http://blog.csdn.net/sum_rain/article/details/37085771 Token,就是令牌,最大的特点就是随机性,不可预测.一般黑客或软件无法猜测出来. ...