关于设置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 ...
随机推荐
- 【Python3爬虫】爬取美女图新姿势--Redis分布式爬虫初体验
一.写在前面 之前写的爬虫都是单机爬虫,还没有尝试过分布式爬虫,这次就是一个分布式爬虫的初体验.所谓分布式爬虫,就是要用多台电脑同时爬取数据,相比于单机爬虫,分布式爬虫的爬取速度更快,也能更好地应对I ...
- 纯数据结构Java实现(4/11)(BST)
个人感觉,BST(二叉查找树)应该是众多常见树的爸爸,而不是弟弟,尽管相比较而言,它比较简单. 二叉树基础 理论定义,代码定义,满,完全等定义 不同于线性结构,树结构用于存储的话,通常操作效率更高.就 ...
- MySQL基础(用的贼鸡儿多)
整理有点乱,业余也玩玩系统,经常碰见这些玩意,有点烦,老是记不住 MySQL 基础语法 一.连接 MYSQL格式: mysql -h 主机地址 -u 用户名 -p 用户密码. 1.连接到本机上的 MY ...
- Python循环语句及函数的定义
循环语句¶ 重复执行某一个固定的动作或者任务 语法 for 变量 in序列: 语句1 语句2 ..... In [2]: # 列表知识只是以后会讲 # 比如[1,2,3,4,5,6,7] list ...
- c++ 按位或
|=是位操作运算符的一种,其形式为:a|=b代表的含义为a=a|b;即把a和b做按位或(|)操作,结果赋值给a.按位或的计算规则为:1 逐位进行计算:2 计算数的同位上值,如果均为0,则结果对应位上值 ...
- 详解golang net之transport
关于golang http transport的讲解,网上有很多文章读它进行了描述,但很多文章讲的都比较粗,很多代码实现并没有讲清楚.故给出更加详细的实现说明.整体看下来细节实现层面还是比较难懂的. ...
- Spring框架入门之基于Java注解配置bean
Spring框架入门之基于Java注解配置bean 一.Spring bean配置常用的注解 常用的有四个注解 Controller: 用于控制器的注解 Service : 用于service的注解 ...
- mysql count(*)与count(1)的区别
count() 对行数进行计算,包括NULL: count(column) 计算特定的列的值的行数,不包括NULL: count(1)这个用法和count()的结果是一样的. http://blog. ...
- Python 命令行之旅:使用 argparse 实现 git 命令
作者:HelloGitHub-Prodesire HelloGitHub 的<讲解开源项目>系列,项目地址:https://github.com/HelloGitHub-Team/Arti ...
- [SNOI2019]字符串
名称:字符串 来源:2019年陕西省选 题目内容 传送门 洛谷(P5392) 题目描述 给出一个长度为$n$的由小写字母组成的字符串$a$,设其中第$i$个字符为$a_i(1≤i≤n)$. 设删掉第$ ...