Unlike Apache 1.3, Apache 2 requires more than one module for mod_proxy functionality. Apache 1.3 requires only mod_proxy for basic proxy support. Apache 2 requires mod_proxy in addition to protocol-specific modules depending on the type of proxying required:
LoadModule proxy_module /path/to/mod_proxy.so
LoadModule proxy_http_module /path/to/mod_proxy_http.so
ProxyRequests off
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
<VirtualHost *:80>
ServerName localhost
UseCanonicalName Off
ProxyPass /other/ http://otherserver:8888/
<Location /other/>
ProxyPassReverse /
</Location>
</VirtualHost>
apachemod_proxyvirtualhost
Use this configure line to configure Apache with all available shared modules:
./configure ... --enable-shared=max
apachecompilationshared-modules
If you need to compile Apache with EAPI, this is one way to get it going:
# CFLAGS="-DEAPI" ./configure --enable-shared=max
apachecompilationeapi
Tired of typing your SSL password on boot of your webserver? You can decrypt it if you're certain it's safe:
# openssl rsa -in server.key -out server.key.unsecure
apachebootcommandsencryptionkeyopensslsecurityshellsslwebserver
Use these commands to generate a self-signed SSL certificate (e.g. for Apache):
# openssl genrsa 1024 > server.key # openssl req -new -key server.key -x509 -days 90 -out server.crt
apachecertificatescommandskeysopensslsecurityssl
If you want to omit traffic from certain hosts (the dev machines, etc) you can add these directives to your configuration block:
SetEnvIf Remote_Addr 192.168.1.99$ do_not_log CustomLog logs/access_log combined env=!do_not_log
*Note: You need to have mod_env installed for this to work.
apacheconfigurationloggingmod_env
To redirect all pages to / with Apache, use mod_rewrite:
RewriteEngine On RewriteRule \/.+ / [L,R]
apacheconfigurationmod_rewriteredirectrewriterules
Clever kill/cat/sed line to refresh the logs for Apache stolen from some documentation somewhere:
# kill -USR1 $(cat $(httpd -V | sed -n '/DEFAULT_PIDLOG/s/.*"\(.*\)"/\1/p'))
apachecommandskillloggingsed
If you want to take your site down for maintenance, but leave your webmail portal active on Sundays, you could put this in either your <VirtualHost> block or in an .htaccess file for your site:
RewriteEngine on
RewriteCond %{TIME_WDAY} 0
RewriteRule !^/mail.* https://path/to/your/maint/page.html
apacheconfigurationhtaccessmod_rewriterewritevirtualhost
Some virtual mapping goodness:
<VirtualHost *> ServerName cprogrammer.org ServerAlias cprogrammer.org *.cprogrammer.org # See the docs for the %-specs; %1 maps to the first part of the # domain (a.b.c.d.e -> a, a.b.c -> a) VirtualDocumentRoot /users/%1/public_html VirtualScriptAlias /users/%1/public_html/cgi-bin/ </VirtualHost>
apacheconfigurationmappingneatvirtualhost