Using Apache's VirtualHost configurations has very little to do with your Internet connection.
Apache configuration:
I'm using VirtualHosts on all of my office's servers, so that people who are running brute force attacks on the IP addresses alone cannot access any of our content/management utilities, because we get a couple of brute forced attacks on phpMyAdmin every single day where they only know the IP address.
If you're using Fedora Core, then the Apache configuration files should be in /etc/httpd/conf.d. If you're using Ubuntu, then the Apache configuration files will be in /etc/apache2/sites-enabled
I'm using Fedora Core and I've added the following VirtualHosts:
- For intruders who don't know my hostname (filename = 0_instruders.conf):
Code:
# Prevent access to .svn folders by showing Not Found page - this is for all the virtualhosts
RedirectMatch 404 /\\..*(/.*|$)
NameVirtualHost *:80
<VirtualHost *:80>
# Server administrator E-mail
ServerAdmin [email protected]
# Make sure that you don't have anything stored in this folder below
DocumentRoot /var/www/html
# Primary identifier of virtual host, which will be ignored/used by default since this file will be loaded first
ServerName intrusions
ErrorLog logs/intrusions-error_log
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\" \"%{Host}i\"" combined_with_host
CustomLog logs/intrusions-access_log combined_with_host
</VirtualHost>
- For people who access my site at www.mydomain.co.za or mydomain.co.za (filename = mydomain_www.conf):
Code:
<VirtualHost *:80>
# Server administrator E-mail
ServerAdmin [email protected]
# Folder with all website contents
DocumentRoot /var/www/mydomain_www
# Primary identifier of virtual host
ServerName www.mydomain.co.za
# Aliases of virtual host
ServerAlias mydomain.co.za
# Logging
ErrorLog logs/mydomain_www-error_log
CustomLog logs/mydomain_www-access_log common
</VirtualHost>
<Directory "/var/www/mydomain_www">
# Allow sym-links, but not indexes
Options FollowSymLinks
# Allow overriding with .htaccess files
AllowOverride All
# Allow everyone access
Order allow,deny
Allow from all
</Directory>
- For people who access my site at admin.mydomain.co.za (filename = mydomain_admin.conf):
Code:
<VirtualHost *:80>
# Server administrator E-mail
ServerAdmin [email protected]
# Folder with all website admin contents
DocumentRoot /var/www/mydomain_admin
# Primary identifier of virtual host
ServerName admin.mydomain.co.za
# Logging
ErrorLog logs/mydomain_admin-error_log
CustomLog logs/mydomain_admin-access_log common
</VirtualHost>
<Directory "/var/www/mydomain_admin">
# Allow sym-links, but not indexes
Options FollowSymLinks
# Allow overriding with .htaccess files
AllowOverride All
# Allow only 10.*.*.* access
Order allow,deny
Allow from 10.
</Directory>
I have also added a deflate.conf file, which will result in javascript & text files being compressed with g-zip if the browser supports it:
Code:
<IfModule mod_deflate.c>
# these are known to be safe with MSIE 6
AddOutputFilterByType DEFLATE text/html text/plain text/xml
# everything else may cause problems with MSIE 6
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/x-javascript application/javascript application/ecmascript text/javascript
AddOutputFilterByType DEFLATE application/rss+xml
</IfModule>
I've renamed all the other configuration files to end with .disabled, except of course my php.conf, phpMyAdmin.conf and the ones I mentioned above
Also make sure that if you're going to make the site available to other people, that you use production values in the php.ini file.
Dynamic DNS configuration:
You should first create a Dynamic DNS account at
www.dyndns.com, which should be free. Then you setup your ADSL modem to make use of this DDNS account.
If you don't like that hostname given by DynDNS, then you can register another domain, and simply setup an CName record to point to your DynDNS.com hostname.
You can register like a .za.net domain for free at
http://za.net/, which is meant for non-profit organisations and private users. Please note that this can take a few weeks even - or at least mine took 3 weeks to register like 5 years ago.
You can also register for a .co.za domain at
http://co.za which would cost you like R50 per year, but the registration would be done within 1 day since they're automating the registration process.