Title | Apache mod_jk VirtualHost 설정 Apache mod_jk VirtualHost setting | ||||||
Writer | 이지섭 | Write Date | Feb 4 2018 | Modify Date | Aug 12 2024 | View Count | 14065 |
[ httpd.conf ]Include the httpd-vhosts.conf file. Create the mod_jk.conf setting file and add it again. # Virtual hosts Include conf/extra/httpd-vhosts.conf ...( skipping )... Include conf/mod_jk.conf [ mod_jk.conf ]Loads the compiled and installed mod_jk.so module. There's a way like JkMount. But use the JkMountFile option to set the URI pattern to work with Tomcat. LoadModule jk_module modules/mod_jk.so <IfModule jk_module> JkWorkersFile conf/workers.properties JkLogFile logs/mod_jk.log JkLogLevel info JkMountFile conf/uri.properties </IfModule> [ workers.properties ]Set the worker's name, port, and type to work when connecting to the Tomcat in mod_jk module. Ports for the ajp13 protocol can be set in the server.xml file of the Tomcat. If there are multiple worker (tomcat) names, separate them into commas (,) and list them in worker.list. worker.list=worker1 worker.worker1.port=8009 worker.worker1.host=localhost worker.worker1.type=ajp13 worker.worker1.lbfactor=1 [ uri.properties ]Let Tomcat process all the files in the first setup (/*). Use the ! (Exclude) pattern to specify the URI pattern to be processed by Apache other than Tomcat. /*=worker1 /*.jsp=worker1 /*.do=worker1 [ httpd-vhosts.conf ]Apply uri.properties setting applied in mod_jk.conf to each VirtualHost (JkMountFile), Add the syntax JkMountFile conf/uri.properties to the last part of each VirtualHost setup. Note that examples of SSL setup are in the conf/extra/httpd-ssl.conf file. # Virtual Hosts # # Required modules: mod_log_config # If you want to maintain multiple domains/hostnames on your # machine you can setup VirtualHost containers for them. Most configurations # use only name-based virtual hosts so the server doesn't need to worry about # IP addresses. This is indicated by the asterisks in the directives below. # # Please see the documentation at # <URL:http://httpd.apache.org/docs/2.4/vhosts/> # for further details before you try to setup virtual hosts. # # You may use the command line option '-S' to verify your virtual host # configuration. # # VirtualHost example: # Almost any Apache directive may go into a VirtualHost container. # The first VirtualHost section is used for all requests that do not # match a ServerName or ServerAlias in any block. # <VirtualHost *:80> ServerAdmin webmaster@some.net DocumentRoot "/usr/local/apache-tomcat-8.5.24/webapps/ROOT" ServerName some.net ServerAlias www.some.net ErrorLog "logs/some.net-error_log" CustomLog "logs/some.net-access_log" common JkMountFile conf/uri.properties </VirtualHost> <VirtualHost *:443> ServerAdmin webmaster@some.net DocumentRoot "/usr/local/apache-tomcat-8.5.24/webapps/ROOT" ServerName some.net ServerAlias www.some.net ErrorLog "logs/some.net-ssl-error_log" CustomLog "logs/some.net-ssl-access_log" common SSLEngine on SSLCertificateFile /etc/pki/tls/private/some.net_20180107B19T.crt.pem SSLCertificateKeyFile /etc/pki/tls/private/some.net_20180107B19T.key.pem SSLCertificateChainFile /etc/pki/tls/certs/chain-bundle.pem SSLCACertificateFile /etc/pki/tls/certs/AddTrustExternalCARoot.crt <FilesMatch "\.(cgi|shtml|phtml|php)$"> SSLOptions +StdEnvVars </FilesMatch> <Directory "/usr/local/apache2/cgi-bin"> SSLOptions +StdEnvVars </Directory> BrowserMatch "MSIE [2-5]" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0 CustomLog "/usr/local/apache2/logs/ssl_request_log" \ "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b" JkMountFile conf/uri.properties </VirtualHost>
When linking Apache and Tomcat by mod_jk module, in mod_jk.conf, the JkMountFile setting is used to specify the URI pattern to be responsible for each server.
The point is that the VirtualHost setup also needs to specify the URI pattern that each server is responsible for.
That way, the Jsp file will be processed by Tomcat.
Set the port and IP of Tomcat, and create each uri.properties file. You can assign each mapping file to the JkMountFile from VirtualHost by host.
Because a worker is specified in the uri.properties file. Several Tomcat can be linked.
(Environment) Apache : httpd-2.4.29 mod_jk : tomcat-connectors-1.2.42 Tomcat : apache-tomcat-8.5.24
[Web page referenced] http://tomcat.apache.org/connectors-doc/reference/uriworkermap.html https://www.lesstif.com/pages/viewpage.action?pageId=12943367 http://truepia.tistory.com/276 The Apache Tomcat Connectors - Reference Guide (1.2.49) - uriworkermap.properties configuration | |||||||