parsed.org

Tips by tag: apache

Apache 2: mod_proxy Configuration by cygnus on Jan 12, 2005 11:06 AM

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
Apache and DSO Support by cygnus on Jan 12, 2005 11:03 AM

Use this configure line to configure Apache with all available shared modules:

./configure ... --enable-shared=max
apachecompilationshared-modules
Compile with EAPI by xinu on Mar 18, 2005 01:34 PM

If you need to compile Apache with EAPI, this is one way to get it going:

# CFLAGS="-DEAPI" ./configure --enable-shared=max
apachecompilationeapi
Decrypt RSA Key by xinu on Sep 10, 2005 12:15 AM

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
Generate a Self-Signed SSL Certificate by cygnus on Apr 11, 2005 07:54 AM

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
Omit Hosts From Logs by xinu on Dec 31, 2005 03:51 PM

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
Redirect All Pages To Root by cygnus on Feb 27, 2007 12:16 PM

To redirect all pages to / with Apache, use mod_rewrite:

RewriteEngine On
RewriteRule \/.+ / [L,R]
apacheconfigurationmod_rewriteredirectrewriterules
Refresh Apache Logs by xinu on Jan 13, 2005 08:45 AM

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
Time-Based Redirection by xinu on Feb 10, 2005 02:20 PM

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
Virtual Mapping by xinu on Jan 13, 2005 08:23 AM

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
RSS