关于设置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为80, 直接运行bin/startup.bat就行了.
2. ubuntu有个iptables NAT
即可控制访问ubuntu系统的请求通过iptables来转发,比如你访问80端口的请求,可以重定向到8080端口上去,
这样tomcat监听的8080端口就能收到80端口的访问请求了.
看一下歪国人的配置:
Iptables redirect port 80 to port 8080
The problem:
- You have a linux server
 - Install tomcat or any other application server
 - You don't want the application server to run as root, therefore it cannot listen to any of the ports 80 (http) or 443 (https)
 - From outside, though, the application server must be accessible on ports 80 / 443
 
The most popular approach:
- Create an ordinary user specificaly for the application server (ex: tomcat)
 - Configure it to listen to a port bigger than 1024 - actually Tomcat comes by default configured to 8080 instead of 80 and 8443 instead of 443
 - Redirect the incoming connections from port 80 to 8080
 
The redirection is done by using the following iptables commands issued in sequence. The first one will configure the machine to accept incoming connections to port 80, the second does the same for port 8080 and the third one will do the actual rerouting. Please proceed in a similar manner for ports 443 forwarded to 8443
iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT
iptables -A INPUT -i eth0 -p tcp --dport 8080 -j ACCEPT
iptables -A PREROUTING -t nat -i eth0 -p tcp --dport 80 -j REDIRECT --to-port 8080
然而事情你总以为算结束了!!!
Chain PREROUTING (policy ACCEPT)
num  target     prot opt source               destination         
1    REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:443 redir ports 8443
2    REDIRECT   tcp  --  0.0.0.0/0            0.0.0.0/0            tcp dpt:80 redir ports 8080
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination
Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    REDIRECT   tcp  --  0.0.0.0/0            127.0.0.1            tcp dpt:80 redir ports 8080
Chain POSTROUTING (policy ACCEPT)
num  target     prot opt source               destination
但是:
$service iptables save
iptables: unrecognized service
WHY!??
http://m.blog.csdn.net/blog/FENGQIYUNRAN/21830541
于是准备着手解决,解决思路很是明了,就是首先确定Linux是否安装了 iptables 。
service iptables status
但是仍然提示:iptables:unrecognized service。准备安装,根据不同的Linux内核选择不同的方法如下:
yum install iptables #CentOS系统
apt-get install iptables #Debian系统
但是提示已经安装,那为什么状态显示是未识别的服务呢?继续找原因。继续研究发现可能是由于没有安装iptables-ipv6,于是采用
sudo apt-get install iptables-ipv6进行安装,但提示Unable to locate package错误得错误。
考虑到软件间的不兼容,无奈先进行更新:sudo apt-get update,更新后重新安装仍然无法解决定位的问题。
于是采用apt-get install iptables*进行所有可能性查找和安装。经过一轮安装后iptables:unrecognized service的问题仍然没有解决。
继续研读相关资料,最终发现问题所在:
关于设置tomcat端口为80的事的更多相关文章
- LInux设置tomcat端口为80
		
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" ...
 - 使用AdvancedInstaller打包web工程设置tomcat端口的方法
		
原文:使用AdvancedInstaller打包web工程设置tomcat端口的方法 1.首先,要把你要打包的tomcat下的server.xml文件删掉,因为tomcat自带的serv ...
 - 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 ...
 - Mac下Tomcat安装&配置&80默认端口设置
		
序言: 在学习Tomcat时, 部署虚拟服务主机时,遇到了无响应的情况.原以为是应为Tomcat默认端口8080在调整至(进行端口转发设置)默认端口80会和Mac自带Apache起冲突.但是也有同学使 ...
 - 配置Tomcat监听80端口、配置Tomcat虚拟主机、Tomcat日志
		
6月27日任务 16.4 配置Tomcat监听80端口16.5/16.6/16.7 配置Tomcat虚拟主机16.8 Tomcat日志扩展邱李的tomcat文档 https://www.linuser ...
 - Tomcat介绍、安装jdk、安装Tomcat、配置Tomcat监听80端口
		
1.Tomcat介绍 2.安装jdk下载:wget -c http://download.oracle.com/otn-pub/java/jdk/10.0.1+10/fb4372174a714e6b8 ...
 - 配置Tomcat监听80端口 配置Tomcat虚拟主机  Tomcat日志
		
配置Tomcat监听80端口 • vim /usr/local/tomcat/conf/server.xml Connector port=" protocol="HTTP/1.1 ...
 - Linux下Tomcat端口、进程以及防火墙设置
		
Linux下Tomcat端口.进程以及防火墙设置 1,查看tomcat进程: #ps -aux | grep tomcat(或者ps -ef | grep tomcat都行) 可以看到现在运行着两个 ...
 - Linux centosVMware 配置Tomcat监听80端口、配置Tomcat虚拟主机、Tomcat日志
		
一.配置Tomcat监听80端口 关闭tomcat报错 [root@davery src]# /usr/local/tomcat/bin/shutdown.sh 重装tomcat即可 vim /usr ...
 
随机推荐
- 洛谷 P2044 [NOI2012]随机数生成器
			
题意简述 读入X[0], m, a, c, n和g $ X[n+1]=(a*X[n]+c)\mod m $ 求X数列的第n项对g取余的值. 题解思路 矩阵加速 设\[ F=\begin{bmatrix ...
 - 普通Apache的安装与卸载
			
Apache安装与卸载ctrl+F快捷查找 1.下载apache 64位解压 官网:http://httpd.apache.org/ 文件使用记事本或者sublime2.修改 打开apache目录下的 ...
 - Yii2 登录报错
			
当用数据库登录系统报如下错误时 PHP Recoverable Error – yii\base\ErrorException Argument 1 passed to yii\web\User::l ...
 - React单页面应用使用antd的锚点跳转失效
			
首先在react项目中引用antd的锚点 import {Anchor} from 'antd';const { Link } = Anchor; <Anchor> <Link hr ...
 - tensorflow学习笔记——多线程输入数据处理框架
			
之前我们学习使用TensorFlow对图像数据进行预处理的方法.虽然使用这些图像数据预处理的方法可以减少无关因素对图像识别模型效果的影响,但这些复杂的预处理过程也会减慢整个训练过程.为了避免图像预处理 ...
 - [luogu4886] 快递员(点分治,树链剖分,lca)
			
dwq推的火题啊. 这题应该不算是点分治,但是用的点分治的思想. 每次找重心,算出每一对询问的答案找到答案最大值,考虑移动答案点,使得最大值减小. 由于这些点一定不能在u的两颗不同的子树里,否则你怎么 ...
 - 【已解决】Https请求—未能创建 SSL/TLS 安全通道
			
在做项目的微信推送消息功能时,由于微信并发量大,导致其它第三方接口调用时直接挂掉报错. 问题: 测试工程师做压测,100个线程同时调用微信和XX站的接口,日志报XX站的“请求被中止: 未能创建 SSL ...
 - Windows 10“数字权利激活”永久性激活!!!
			
直接运行软件即可自动激活,等出现"激活成功"即可关闭软件. 注意事项: 激活软件不会帮你打开Windows update服务,如关闭系统自动更细服务的需要先启动服务. 可以在小娜搜 ...
 - cython 第一次接触
			
https://www.cnblogs.com/kaituorensheng/p/4452881.html
 - MySQL之binlog日志
			
一.什么是binlog binlog 是一个二进制格式的文件,用于记录用户对数据库 更新的SQL语句 信息,例如更改数据库表和更改内容的SQL语句都会记录到binlog里,但是对库表等内容的查询不会记 ...