As a continuation of Tomcat installation and auto-start settings, I summarized the settings to throw the HTTP request received on the Apache side to Tomcat.
[root@akagi ~]# yum install -y httpd
[root@akagi ~]# httpd -v
Server version: Apache/2.4.6 (CentOS)
Server built: Aug 8 2019 11:41:18
[root@akagi ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@akagi ~]# systemctl list-unit-files -t service | grep httpd
httpd.service enabled
/etc/httpd/conf.modules.d/00-proxy.conf
describes the settings of the modules used for the reverse proxy.mod_proxy.so
and mod_proxy_ajp.so
are listed and not in the comment line.#
, it will be a comment line.mod_proxy_ajp
allows you to communicate with Tomcat using a protocol called AJP, which is more efficient than HTTP.mod_jk
and mod_jk2
a long time ago, but before I knew it, the module I used changed ...00-proxy.conf
# This file configures all the proxy modules:
LoadModule proxy_module modules/mod_proxy.so
...
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
...
[root@akagi ~]# cd /etc/httpd/conf/
[root@akagi conf]# cp -a httpd.conf httpd.conf.org
ProxyPass {request pass} ajp: // localhost: 8009 / {Java app context name}
ProxyPassReverse {request path} ajp: // localhost: 8009 / {Java application context name}
http: // {server IP} / tomcat9 /
, the context name on port 8009 of the local host (localhost)/
(* Tomcat management screen) It is set to transfer./etc/httpd/conf/httpd.conf
#Add the following to the end of the file
ProxyPass /tomcat9/ ajp://localhost:8009/
ProxyPassReverse /tomcat9/ ajp://localhost:8009/
test
running on Tomcat, the settings will be as follows.tomcat9
with any character string./etc/httpd/conf/httpd.conf
#Add the following to the end of the file
ProxyPass /tomcat9/ ajp://localhost:8009/test/
ProxyPassReverse /tomcat9/ ajp://localhost:8009/test/
service httpd graceful
is executed, instead of forcibly restarting Apache, only the setting value is reflected, but in CentOS 7 series Apache, graceful
Cannot be used.systemctl reload httpd
with reload
has the same effect as the traditional graceful
. It seems that you can get it.[root@akagi ~]# systemctl reload httpd
http: // {server IP} / tomcat9 /
and check that you can see the management screen of Tomcat.Recommended Posts