[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Osaka/Yokohama/Tokushima] Looking for infrastructure/server side engineers!

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Deployed by over 500 companies] AWS construction, operation, maintenance, and monitoring services

[Successor to CentOS] AlmaLinux OS server construction/migration service

[Successor to CentOS] AlmaLinux OS server construction/migration service

[For WordPress only] Cloud server “Web Speed”

[For WordPress only] Cloud server “Web Speed”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Cheap] Website security automatic diagnosis “Quick Scanner”

[Reservation system development] EDISONE customization development service

[Reservation system development] EDISONE customization development service

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Registration of 100 URLs is 0 yen] Website monitoring service “Appmill”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[Compatible with over 200 countries] Global eSIM “Beyond SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[If you are traveling, business trip, or stationed in China] Chinese SIM service “Choco SIM”

[Global exclusive service] Beyond's MSP in North America and China

[Global exclusive service] Beyond's MSP in North America and China

[YouTube] Beyond official channel “Biyomaru Channel”

[YouTube] Beyond official channel “Biyomaru Channel”

When using internal ELB with tomcat integration with Apache 2.4, a "too long" error occurs

My name is Ito and I am an infrastructure engineer.

I think it's common for AWS server configurations to have a web server receive access and then proxy the request to the application server behind it

In this case, when considering availability, it is better to make each server redundant.
So this is the configuration.


I think this is a common configuration where Apache is used as the web server and Tomcat is used as the application server

So, I got stuck when Apache threw it to tomcat, so I would like to leave the solution.

I got stuck with ProxyPass settings

Write a description in Apache's virtual host to forward the received requests to tomcat.

ProxyPass / ajp://internal-elb-xxxxxxxxxxxxxx.ap-northeast-1.elb.amazonaws.com:8009/

I am using ProxyPass to send requests to ajp's 8009 port.
What is written as "internal-elb-~~" is the internal ELB.

However, if you check Apache's syntax in this state, the following error will be output.

# httpd -t ProxyPass worker hostname (internal-elb-xxxxxxxxxxxxxx.ap-northeast-1.elb.amazonaws.com) too long

The host name sent to ProxyPass is too long...
Even if you say that, the internal ELB host name will look like this, and the IP address is not fixed, so what should I do? !
It became.

Compatible with Rewrite rules

In this configuration, it would be OK if ProxyPass could just send it to tomcat, so
I changed the rules as below.

RewriteEngine on RewriteRule ^/(.*)$ ajp://internal-elb-xxxxxxxxxxxxxx.ap-northeast-1.elb.amazonaws.com:8009/$1 [P,L]

Use rewrite rules.
As a rewrite, the rule is to throw it to ajp if it comes to everything.

Now you can safely send Apache requests to Tomcat (internal ELB).

If you found this article helpful , please give it a like!
0
Loading...
0 votes, average: 0.00 / 10
4,665
X facebook Hatena Bookmark pocket
[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[2025.6.30 Amazon Linux 2 support ended] Amazon Linux server migration solution

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

[Osaka/Yokohama] Actively recruiting infrastructure engineers and server side engineers!

The person who wrote this article

About the author