首页 > 其他分享 >Run tomcat on port 80 not 8080

Run tomcat on port 80 not 8080

时间:2023-11-06 14:32:46浏览次数:35  
标签:iptables Run Tomcat sudo run 8080 80 port

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.

# 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:

<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:

TOMCAT_USER="root"

And restart Tomcat:

 

sudo service tomcat7 restart

 

REF:

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

 



标签:iptables,Run,Tomcat,sudo,run,8080,80,port
From: https://blog.51cto.com/emanlee/8207370

相关文章

  • How do I run Adobe Flash on Chrome?
     ToenableFlashforaspecificwebsite,firstopenyourChromebrowserandtypechrome://settings/contentintheaddressbar,thenpressenter.ThenontheContentSettingspage,scrolldownandclicktheFlashbuttonMakesurethatthetoggleissetto......
  • Eclipse: export project such that Windows and Mac can both run it (SWT)
     [root@localhostaimin]#java-jarTASTS.jarExceptioninthread"main"java.lang.UnsatisfiedLinkError:CouldnotloadSWTlibrary.Reasons:   noswt-win32-4930r7injava.library.path   noswt-win32injava.library.path   Can'tloadlibr......
  • 无线局域网(802.11体系结构和协议栈)
    无线LAN越来越普及,家庭、办公室、咖啡厅、图书馆、机场、动物园等公共场所都有相应的设施,通过它们可以把就计算机、PDA和智能手机连接到Internet。无线局域网也可用来使得附近的两台或多台计算机直接进行通信而无须接入Internet。无线局域网的主要标准是802.11。在以下内容中,我们......
  • 创新思维:腾讯产品经理如何解决一头800kg牛的过桥难题?
    亲爱的小伙伴们,大家好!我是小米,一个热爱技术、热爱分享的90后,今天我要和大家一起探讨一道经典的面试题——“腾讯产品经理面试题:一头牛重800kg,一座桥承重700kg,牛该怎么过桥?”这个问题看似简单,但其实蕴含着许多深刻的思考,非常值得我们一起来解析。面试的重点这个问题既考察了数学和物......
  • Shell系列---【常用脚本之---java启动脚本:run.sh】
    run.sh#!/bin/sh-lapplication=node_exporterPORT=1888CUR_IP=${hostname-I|awk'{print$1}'}command="/opt/app/middles/node_exporter/node_exporter--web.listen-address=:$PORT"#停止stop(){ echo"=============================......
  • 题解 P6880 [JOI 2020 Final] オリンピックバス
    洛谷。题意应该显然,注意最多只能翻转一条边,并且可以不翻转。分析首先观察数据范围\(2\leN\le200\),\(1\leM\le5\times10^4\),可以发现我们的\(N\)和\(M\)并不是同级的,因此,在众多的最短路算法中,我们应当选择不加堆优化的dijkstra算法,并且使用邻接矩阵,这是\(O(n^2)......
  • 牛客小白月赛80C/D又放学辣
    C这么小的数据范围,想必胡搞就可以了。#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>usingnamespacestd;intn,m,k;structcll{intp;intid;}cl[105];intx;intans[205];boolcmp(cllx,clly){returnx.p......
  • Error: error:0308010C:digital envelope routines::unsupported
    "start":"SETNODE_OPTIONS=--openssl-legacy-provider&&cross-envUMI_ENV=devumidev","start:dev":"SETNODE_OPTIONS=--openssl-legacy-provider&&cross-envREACT_APP_ENV=devMOCK=noneUMI_ENV=devu......
  • P9801 [NERC2018] King Kog’s Reception
    题目传送门前置知识线段树解法第一眼感觉和luoguP1083[NOIP2012提高组]借教室很像。本题同样采用线段树维护,\(sum_{l,r}(1\lel\ler\le10^6)\)表示从\(l\simr\)时刻内骑士拜访的总时间,\(maxx_{l,r}(1\lel\ler\le10^6)\)表示从\(l\simr\)时刻内骑士......
  • Oracle 19c Linux平台启动时出现ORA-00800错误浅析
    这里简单介绍一下如何处理解决Linux平台下Oracle19c启动时,告警日志出现ORA-00800错误的问题,详情介绍请见下面内容:环境描述:操作系统:RedHatEnterpriseLinuxrelease8.8(Ootpa)数据库:19.16.0.0.0企业版问题描述:在Oracle19c启动时,在Oracle的告警日志中会出现下面这样一......