Entri Populer

Monday, March 28, 2011

Apache 2 SSL and Redirection

Now, i need to create ssl for my domain netmon.foo.com. therefore i do the following :
1. Make sure Apache2 mod ssl is install and enable
    To activate SSL module on Apache 2, issue this command : a2enmod ssl
    The above command only apply when you already install Apache2 mod ssl but not enable it yet
2. Make sure Openssl is install on my Linux box
3. after making sure all the above item are completed, then type  in :
    openssl req -new -x509 -days 365 -keyout path_to_my_apache_key_directory/virtualhost1.key -out path_to_my_apache_crt_directory/virtualhost1.crt  <Hit Enter>


    The system will then ask for Country Code, City, Organizational Unit, Company Name, Common Name. 
    Fill   in all the above field but make sure the Common Name reflect your website domain name, otherwise you might end up with name certificate does not match with website domain name error.
check out these links :
a. apache-2-ssltls-step-step-part-1 
b. apache-ssl-deflate 
Next step, i need to configure your virtualhost1.conf and create new configuration for the website that will be access via https. 
The configuration may look like this :

NameVirtualHost *:443
<VirtualHost *:443>
    ServerName netmon.foo.bar
    DocumentRoot path_to_my_server_web_server_directory

    SSLEngine On                                                                                                                                                      
    SSLCertificateFile path_to_my_apache_crt_directory/virtualhost1.crt                                                                                                                         
    SSLCertificateKeyFile path_to_my_apache_key_directory/virtualhost1.key                                                                                                                      
    <Location />                                                                                                                                                        
    SSLRequireSSL On                                                                                                                                                    
    SSLVerifyClient optional                                                                                                                                            
    SSLVerifyDepth 1                                                                                                                                                    
    SSLOptions +StdEnvVars +StrictRequire                                                                                                                               
    </Location>
        <Directory path_to_my_server_web_server_directory>
        Options +FollowSymLinks
        AllowOverride None
        order allow,deny
        allow from all
        AddType application/x-httpd-php .php
        DirectoryIndex index.php

     </Directory>
</VirtualHost>
Restart the apache service and try the connection https://netmon.foor.bar 


As additional i also want to redirect regular http request http://netmon.foo.bar to https://netmon.foo.bar. I create new virtualhost configuration name netmon-http.


The content of netmon-http :

NameVirtualHost *:80
<VirtualHost *:80>
Servername netmon.foo.bar
Redirect / https://netmon.foo.bar
</VirtualHost> 


Restart the Apache service again and then try to open http://netmon.foo.bar, then it will be redirect to https://netmon.foo.bar


Thanks to Triprasetyono for the help








Wednesday, March 23, 2011

SATA Ext Drive driver for Windows 7

I want to use my data from my old laptop, It's 300 GB SATA drive. I have install Win 7 on my new laptop but some how the SATA External drive could not be recognize by Win 7.

Prof Google save my day, i found detecting-esata-drive-in-windows-7

Immediately i download the utility, install it on my Win 7..... and my External Sata HD can be recognize..  wuhuuuuu... i got my data back....

Monday, March 21, 2011

Change Nagios Sender Address

I need to change the Nagios Sender Address on my server, by default Nagios will set it to "Nagios@Servername" as it sender address. So whenever you receive mail notification from nagios, you will see "Nagios@Servername" on the sender field.

After browsing around, i found : how-do-i-change-email-address-opsview-emails

Since i use postfix on my machine, then i do as instructed :
1. On postfix main.cf file, i added smtp_generic_maps = /etc/postfix/generic (path where your postfix installation)
2. Create file with generic as it name
3. On that file, add a line nagios@servername  alert@mycompanydomain. Save and Exit
4. On linux console, type postmap generic then hit enter.
5. Restart postfix service

and i got what i needed.

Note :
a. You can change generic into whatever filename you like, but make sure on main.cf you also write the same filename.
b. In the link above, you can find other solution for exim4 and sendmail too

Thanks to awijntje