Saturday, 8 March 2014

Case-Insensitive Redirect


<LocationMatch "(?i)^/Site/Website(.*)$">
                RedirectMatch "(?i)^/Site/Virtual(.*)$" http://example.com/Site/Virtual

</LocationMatch>

(?i): how we tell the matching engine to treat the text in a case-insensitive manner.

Apache Case-Insensitive Reverse Proxy

Apache ProxyPass directive is case sensitive, this directive differentiates between example.com/Site and same as example.com/site or any of the 16 different permutations (SitE, sITE, ...)

Regex to the rescue:

ProxyPassMatch "(?i)/Site(.*)$" http://192.168.1.1/Site/$1

(?i): case-insensitive match
(.*): zero or more character
$1: trailing text after match sting in the original string. for example (/site/index.html)

Be careful with the trailing /

Thursday, 1 November 2012

Saturday, 20 October 2012

Remove Passkey from a Private Key

openssl rsa -in private_key_with_pass.key -out private_key_without_pass.key

Saturday, 1 September 2012

Convert Apache SSL Private Key to IIS Private Key

To convert private key being used with Apache (usually .key) to IIS private key (.pfx) use the following command:

openssl pkcs12 -export -out private.pfx -inkey private.key -in public.crt

You'll be asked for the password to unlock current private.key (in case it's password protected) and another password to be assigned to the new private.pfx file.

Saturday, 25 August 2012

Don't Reverse Proxy a Subdirectory

Assume you have a reversed web server via apache mod_proxy, there might be subdirectories which you don't want to reverse (such as internal Web Services), you can use ! directive like this:

--------------------------------------------------

<VirtualHost *:80>
    ServerName www.example.com
    ProxyPass /webservice !
    ProxyPass / http://10.1.1.100/
    ProxyPassReverse / http://10.1.1.100/
</VirtualHost>
--------------------------------------------------

It's important to have ! directive before the actual ProxyPass direct.