we already seen how HTTP protocol works. When we developing WEB applications, we also used to encounter an similar stuff named "HTTPD", what's hell is that ?
What is HTTPD ?
HTTPD is the daemon of Apache HTTP Server : is an effort to develop and maintain an open-source HTTP server for modern operating systems including UNIX and Windows NT.
Why we using HTTPD?
Tomcat already provide HTTP service. After deploy web application at Tomcat, we can already access application through the default 8080 port. So why we have to use another HTTP Server ?
The reason is :
- Improve the performance when processing static documents
- Load balancing and Fault tolerant
- Uninterrupted updating applications
There are three ways to integrate Tomcat with HTTPD
- JK
- Http_proxy
- ajp_proxy
What is AJP ?
Apache JServ Protocol (AJP) is a binary protocol that can proxy inbound requests from a web server through to an application server that sits behind the web server.
When using a single server, the performance when using a native webserver in front of the Tomcat instance is most of the time significantly worse than a standalone Tomcat with its default HTTP connector, even if a large part of the web application is made of static files. If integration with the native webserver is needed for any reason, an AJP connector will provide faster performance than proxied HTTP. AJP clustering is the most efficient from the Tomcat perspective. It is otherwise functionally equivalent to HTTP clustering.
How to configure ajp_Proxy ?
ajp_proxy is started from Apache 2.2
Precondition: For Apache (2.2) proxy_ajp.conf
LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
A conf example:
less /etc/httpd/conf.d/000_villim.net.conf
The content of 000_villim.net.conf
<VirtualHost XX.XX.XX.XX:80> ServerName villim.net ErrorLog /var/log/httpd/villim.net.log CustomLog /var/log/httpd/villim.net-access.log combined DocumentRoot "/var/www/html" RedirectMatch ^/$ https://villim.net/feedback/ ProxyPass /feedback ajp://villim.net:8009/feedback ProxyPass /adresboek ajp://localhost:8009/adresboek ProxyPass /restservice ajp://villim.net:8009/lrestservice </VirtualHost>