Linux Ask!

Linux Ask! is a Q & A web site specific for Linux related questions. Questions are collected, answered and audited by experienced Linux users.

May 162011
 

Why SSL cannot be used with name-based virtual hosts?

Answer:

The reason is pretty simple: If you are using a single IP but with many virtual hosts, each virtual hosts has their own certificate and private key. Without looking at the Host header in the incoming HTTP request, Apache will not be able to route the request to the designated virtual hosts. The core problem is, the incoming requests are encrypted so we are not able to tell which key should be used for decryption!

So only IP-based virtual hosts works if you need SSL.

May 062011
 

Limit Apache only listen to IPv4 address

Answer:

Apache httpd web server might listen IPv6 address if your system support IPv6.

To disable IPv6 supprt, add the following lines to the Apache configuration (httpd.conf)

# Listen 80
Listen 0.0.0.0:80 # New value

Restart Apache to take effect

# apachectl -k graceful

Dec 312010
 

Block request by user agent in Apache

Answer:

If you want to block request to your web site, by user agent string, you can change by editing the Apache's configuration.

Add the following lines to the Apache configuration (httpd.conf)

RewriteCond %{HTTP_USER_AGENT} googlebot
RewriteRule . - [F,L]

The above config block all requests from Google's Bot. (Make sure mod_rewrite is installed and enabled)

Also, remember to restart Apache to take effect

# apachectl -k graceful

Dec 302010
 

Turn off directory listing in Apache

Answer:

If you web site's directory without a valid default index page, e.g. index.html, Apache might list all files inside the directory. If you want to turn off, do the following.

Add the following lines to the Apache configuration (httpd.conf)

Options All -Indexes  

Restart Apache to take effect

# apachectl -k graceful