The OpenLogic Technical Support Team fields lots of questions on Apache HTTP Server and over 500 other open source packages. They’ve distilled decades of experience and hundreds of Apache support issues down to the most common questions.
| General Questions | |
|---|---|
| How do I connect Apache 2.2 HTTP Server with two or more remote Tomcat servers? | Create a ReverseProxy from Apache to Tomcat. The best way is to use mod_proxy, mod_proxy_ajp and mod_proxy_balancer. To do this, perform the following steps.
1. When you build Apache from source add these flags: --enable-proxy-ajp --enable-proxy-balancer --enable-proxy 2. Set up your cluster by doing this: <Proxy balancer://tomcat_cluster> BalancerMember ajp://192.168.1.1:8009 BalancerMember ajp://192.168.1.2:8009 BalancerMember ajp://192.168.1.3:8009 </Proxy> 3. Then, add the Rewrite rule that will Proxy the request to your cluster.
RewriteEngine On
RewriteRule ^/(.*)$ balancer://tomcat_cluster%{REQUEST_URI}
[P,QSA,L]
|
| How do I change the log settings to add a cookie? |
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\"
\"%{User-Agent}i\"\"%{Cookie}i\"" combined
|
| What is the best way to add the server-status module to an Apache server if you have a local monitoring engine like Nagios or Hyperic or Tivoli? | Complete the following:
1. Add the the status_module to your apache configuration. 2. Then configure a virtualhost for server-status only access, edit x as follows: <VirtualHost 127.0.0.1:80> <Location /server-status> SetHandler server-status Order Deny,Allow Deny from all Allow from localhost Allow from 127.0.0.1 </Location> </VirtualHost> Now you can access the Apache status screen using this url http://127.0.0.1/server-status ONLY from localhost. |
| How should I configure mod_deflate? | Perform the following steps:
1. Enable the deflate_module in your Apache configuration file (httpd.conf) OR build mod_deflate into the Apache binary using the Apache source and the configure script. 2. If you have an rpm install, add this in the httpd.conf: LoadModule deflate_module modules/mod_deflate.so 3. If you have compiled Apache from source, recompile with these flags: /configure --prefix=/usr/local/ --enable-deflate 4. To enable mod_deflate in the httpd.conf add this:
<IfModule deflate_module>
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/atom_xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
AddOutputFilterByType DEFLATE application/x-httpd-php
AddOutputFilterByType DEFLATE application/x-httpd-fastphp
AddOutputFilterByType DEFLATE application/x-httpd-eruby
AddOutputFilterByType DEFLATE text/html
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
DeflateFilterNote Input instream
DeflateFilterNote Output outstream
DeflateFilterNote Ratio ratio
LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate
CustomLog logs/deflate_log deflate
</IfModule>
This will enable mod deflate for most text and XML files on your site, and, for debugging only, you will have a log file in logs/deflate_log that you can look at to see how effective the module is. |
| How do I rotate my Apache log files? | Like many log file rotation applications, logrotate:(http://iain.cx/src/logrotate/) can be managed as follows:
1. Stop the server. 2. Rename the old log file (date.logfile or logfile.1, for example). 3. Compress the archived log. 4. Restart the server. The current running log file will have the same name as the original so it should not be necessary to change your monitoring routines. We typically recommend using a general purpose utility like logrotate (which is actually a shell script) rather than a custom script, as this centralizes all the log file rotation on the server to a common set of configuration files. This way you can leverage the support of the logrotate community as well as other system administrators. |
| Why is my Apache file size limited to 1.5MB? | You can use the maxPostSize option to adjust this setting. Do not set your maxPostSize value to “=0″ as this would expose you to malicious code execution (i.e., crash the server). Additionally, the maxPostSize setting should be set to a real number.
For instance, maxPostSize=1600000 would allow 16 megabyte files. |
