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. css 渐变动画

    就是这样 这是一段可选文字 -------------------------------------- 代码如下 CSS代码: @media all and (-webkit-min-device- ...

  2. 斯坦福大学自然语言处理第四课“语言模型(Language Modeling)”

    http://52opencourse.com/111/斯坦福大学自然语言处理第四课-语言模型(language-modeling) 一.课程介绍 斯坦福大学于2012年3月在Coursera启动了在 ...

  3. Sitecore营销自动化

    增加与战略性自动化营销系统的互动 Sitecore营销自动化基于DMS中的Sitecore个性化功能.营销自动化系统使用诸如位置,设备和先前访问或购买之类的客户数据来影响用户沿着购买路径的旅程.这些系 ...

  4. jQuery筛选--first()和last()

       first() 概述 获取匹配的第一个元素    last() 概述 获取匹配的最后个元素 <!DOCTYPE html> <html> <head> < ...

  5. windows10 安装 mysql8.0.12 详解

    [1]下载安装包 官网下载地址:https://downloads.mysql.com/archives/community/ 如下图所示: 下载完成,安装包为mysql-8.0.12-winx64. ...

  6. 爬虫万金油,一鹅在手,抓遍全球:goose 简介!

    GOOSE 现已弃用 经过多年的服务,GOOSE接口和支持它的MySQL数据现已弃用 . 在我们进行替换的同时,我们建议寻找一般查询功能的用户在http://rdf.geneontology.org上 ...

  7. js里用append()和appendChild有什么区别?

    parentNode.append()是还在试用期的方法,有兼容问题.是在parendNode节点中最后一个子节点后插入新Node或者DOMString(字符串,插入后为Text节点). 与paren ...

  8. [转载]tnsnames.ora监听配置文件详解

    监听配置文件             为了使得外部进程 如 CAMS后台程序 能够访问 Oracle 数据库 必须配             置 Oracle 网络服务器环境 配置 Oracle 网络 ...

  9. MVC 部署HTTPS网站

    一.项目配置 什么是全站HTTPS 全站HTTPS就是指整个网站的所有页面,所有资源全部使用HTTPS链接.当用户的某个请求是明文的HTTP时,应该通过HTTP状态码301永久重定向到对应的HTTPS ...

  10. 自写Jquery插件 Tab

    原创文章,转载请注明出处,谢谢!https://www.cnblogs.com/GaoAnLee/p/9067017.html 每每看到别人写的Jquery插件,自己也试着学习尝试,终有结果,废话不多 ...