Apache Proxy Support
编辑/etc/httpd/conf/httpd.conf
LoadModule proxy_module modules/mod_proxy.so
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
tomcat配置不变
centos.jsp
[root@centos1 conf]# more /jspre/tomcat7/webapps/ROOT/centos.jsp
<%
out.print("<font color=red>hello centos 1</font>");
out.print("<hr>"+request.getServerName()+":"+request.getServerPort());
%>
<%=session.getId()%>
[root@centos1 conf]#
访问www.nba.edu/centos.jsp
访问www.nba.edu:8080/centos.jsp
修改tomcat配置
server.xml
<Connector port="8080" protocol="HTTP/1.1"
proxyName="www.aaaanba.edu"
proxyPort="80"
connectionTimeout="20000"
redirectPort="8443" />
浏览器访问
防火墙firewalld
防火墙启动状态
[root@centos1 conf]# systemctl list-unit-files | grep "firewalld"
firewalld.service enabled
[root@centos1 conf]# systemctl status firewalld.service
鈼?firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2018-01-10 00:59:57 CST; 1min 48s ago
Docs: man:firewalld(1)
Main PID: 22377 (firewalld)
CGroup: /system.slice/firewalld.service
鈹斺攢22377 /usr/bin/python -Es /usr/sbin/firewalld --nofork --nopid
Jan 10 00:59:56 centos1 systemd[1]: Starting firewalld - dynamic firewall daemon...
Jan 10 00:59:57 centos1 systemd[1]: Started firewalld - dynamic firewall daemon.
浏览器不能直接访问8080,只能通过代理访问
防火墙停止状态
[root@centos1 conf]# systemctl stop firewalld.service
[root@centos1 conf]# systemctl status firewalld.service
鈼?firewalld.service - firewalld - dynamic firewall daemon
Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
Active: inactive (dead) since Wed 2018-01-10 01:02:07 CST; 3s ago
Docs: man:firewalld(1)
Process: 22377 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
Main PID: 22377 (code=exited, status=0/SUCCESS)
Jan 10 00:59:56 centos1 systemd[1]: Starting firewalld - dynamic firewall daemon...
Jan 10 00:59:57 centos1 systemd[1]: Started firewalld - dynamic firewall daemon.
Jan 10 01:02:06 centos1 systemd[1]: Stopping firewalld - dynamic firewall daemon...
Jan 10 01:02:07 centos1 systemd[1]: Stopped firewalld - dynamic firewall daemon.
[root@centos1 conf]#
Apache jk Support
解压源代码
[root@centos1 tmp]# ll tomcat-connectors-1.2.46-src.tar.gz
-rw-r--r--. 1 root root 3252837 Jun 29 2018 tomcat-connectors-1.2.46-src.tar.gz
[root@centos1 tmp]# tar -xzvf tomcat-connectors-1.2.46-src.tar.gz
配置
[root@centos1 native]# pwd
/tmp/tomcat-connectors-1.2.46-src/native
[root@centos1 native]# ./configure
checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
checking target system type... x86_64-pc-linux-gnu
checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... configure: error: newly created file is older than distributed files!
Check your system clock
[root@centos1 native]#
将时间改新
[root@centos1 native]# date -s 20181111
再运行configure
checking for target platform... unix
no apache given
no netscape given
configure: error: Cannot find the WebServer
[root@centos1 native]#
安装httpd-devel包
[root@centos1 native]# which apxs
/usr/bin/apxs
[root@centos1 native]# rpm -qf /usr/bin/apxs
httpd-devel-2.4.6-80.el7.centos.x86_64
[root@centos1 native]#
再运行configure
[root@centos1 native]# ./configure --help | grep "apx"
--with-apxs[=FILE] Build shared Apache module.
FILE is the optional pathname to the apxs tool;
defaults to finding apxs in your PATH.
[root@centos1 native]# find ./ -name "mod_jk.so"
[root@centos1 native]# ./configure --help | grep "apx"
--with-apxs[=FILE] Build shared Apache module.
FILE is the optional pathname to the apxs tool;
defaults to finding apxs in your PATH.
[root@centos1 native]# ./configure --with-apxs=/usr/bin/apxs
[root@centos1 native]#make
[root@centos1 native]#
生成mod_jk.so
[root@centos1 native]# find ./ -name "mod_jk.so"
./apache-2.0/.libs/mod_jk.so
./apache-2.0/mod_jk.so
[root@centos1 native]#
复制mod_jk.so到httpd的modules
[root@centos1 native]# find / -name "mod_jk.so"
/tmp/tomcat-connectors-1.2.46-src/native/apache-2.0/.libs/mod_jk.so
/tmp/tomcat-connectors-1.2.46-src/native/apache-2.0/mod_jk.so
/usr/lib64/httpd/modules/mod_jk.so
[root@centos1 native]#
编辑/etc/httpd/conf/httpd.conf
LoadModule jk_module modules/mod_jk.so
ProxyPass / http://localhost:8080/
ProxyPassReverse / http://localhost:8080/
代理访问 centos.jsp