When mod_proxy_balancer and mod_jk are used together in Apache, the response code is 500.

Asked 1 years ago, Updated 1 years ago, 101 views

Hello, I'm Web developer Navureungi.

We want to create an environment as similar as possible to the operating system with the aim of testing problems that arise when you upload a web application to the operating system in advance. The operating system will have an L4 switch, so we're going to have an Apache do what the L4 does.

Here's how the server works and what I'm trying to do:

The values set for this are as follows::

apache0 httpd.conf:

# omitted

LoadModule authn_file_module modules/mod_authn_file.so
LoadModule authn_core_module modules/mod_authn_core.so
LoadModule authz_host_module modules/mod_authz_host.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule authz_core_module modules/mod_authz_core.so
LoadModule access_compat_module modules/mod_access_compat.so
LoadModule auth_basic_module modules/mod_auth_basic.so
LoadModule socache_shmcb_module modules/mod_socache_shmcb.so
LoadModule reqtimeout_module modules/mod_reqtimeout.so
LoadModule filter_module modules/mod_filter.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule mime_module modules/mod_mime.so
LoadModule log_config_module modules/mod_log_config.so
LoadModule env_module modules/mod_env.so
LoadModule expires_module modules/mod_expires.so
LoadModule headers_module modules/mod_headers.so
LoadModule setenvif_module modules/mod_setenvif.so
LoadModule version_module modules/mod_version.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule session_module modules/mod_session.so
LoadModule session_cookie_module modules/mod_session_cookie.so
LoadModule session_dbd_module modules/mod_session_dbd.so
LoadModule slotmem_shm_module modules/mod_slotmem_shm.so
LoadModule lbmethod_byrequests_module modules/mod_lbmethod_byrequests.so
LoadModule unixd_module modules/mod_unixd.so
LoadModule status_module modules/mod_status.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule dir_module modules/mod_dir.so
LoadModule alias_module modules/mod_alias.so
LoadModule rewrite_module modules/mod_rewrite.so

# Omitted

ProxyRequests off
ProxyPreserveHost on

<Proxy *>
    AddDefaultCharset off
    Order deny,allow
    Allow from all
</Proxy>

ProxyVia On

<VirtualHost *:80>
    ServerName mydomain.com

    <Proxy "balancer://focluster">
        BalancerMember http://mydomain.com:1081/
        BalancerMember http://mydomain.com:1082/
    </Proxy>
    ProxyPass "/" "balancer://focluster"
</VirtualHost>

apache1 httpd.conf:

# omitted

LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info

<VirtualHost *:1081>
    ServerName mydomain.com
    JkMount "/*" fo
</VirtualHost>

apache1 workers.properties:

worker.template.type=ajp13
worker.list=fo
worker.fo.reference=worker.template
worker.fo.port=8011
worker.fo.host=localhost

apache2 httpd.conf:

# omitted

LoadModule jk_module modules/mod_jk.so
JkWorkersFile conf/workers.properties
JkLogFile logs/mod_jk.log
JkLogLevel info

<VirtualHost *:1082>
    ServerName mydomain.com
    JkMount "/*" fo2
</VirtualHost>

apache2 workers.properties:

worker.template.type=ajp13
worker.list=fo2
worker.fo2.reference=worker.template
worker.fo2.port=8012
worker.fo2.host=localhost

Additionally, the WAS web root has index.jsp and test.html, and Tomcat web.xml's welcome-file is index.jsp.

After you set it up, connect to mydomain.com in your browser and you'll see index.jsp well. However, if you request mydomain.com/test.html or a URL that needs to go through the servlet, the 500 status value will be answered. If you check the log, the access up to apache0 is captured. However, there is no access to apache1 and the WAS log does not capture anything. If the page is displayed normally when tested without proxy balance setting, there is nothing wrong with the jk setting or WAS.

Just try ProxyPass without BalancerMember as follows:

<VirtualHost *:80>
    ServerName mydomain.com
    ProxyPass          "/" "http://mydomain.com:1081/"
    ProxyPassReverse   "/" "http://mydomain.com:1081/"
</VirtualHost>

It works well again. I just added a load balance to this setting. I don't know what's wrong. Please answer if you know.

apache tomcat mod_proxy mod_proxy_balancer mod_jk

2022-09-21 23:19

1 Answers

There seems to be no particular setup error....

ProxyPass "/" "balancer://focluster"

Test with / at the end as follows.

ProxyPass "/" "balancer://focluster/"


2022-09-21 23:19

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.