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).