set up DNS wildcard for blah.dev
BIND configuration
/etc/bind/named.conf.localzone "dev" {
type master;
file "/etc/bind/db.dev";
};
run"named-checkconf named.conf.local"
/etc/bind/db.dev: use the loopback address so the IP address is not affected by DHCP.dev. 86400 IN SOA dev. hostmaster.dev. (
20111101; serial yyyy-mm-dd
10800; refresh every 15 min
3600; retry every hour
3600000; expire after 1 month +
86400 ); min ttl of 1 day
IN NS dev.
IN MX 10 dev.
IN A 127.0.0.1
*.dev. IN A 127.0.0.1
named-checkzone dev db.dev
DHCP client configuration
- uncomment the line in /etc/dhcp/dhclient.conf: prepend domain-name-servers 127.0.0.1;
- sudo dhclient
- sudo /etc/init.d/bind9 restart
Testing
ping blah.dev will return 127.0.0.1
disable dnsmasq from networkmanager
sudo vim /etc/NetworkManager.conf. comment out dnsmasq
Install and configure dnsmasq
ping blah.dev will return 127.0.0.1
Set up dnsmasq for local DNS cache and DHCP
disable dnsmasq from networkmanager
sudo vim /etc/NetworkManager.conf. comment out dnsmasq
sudo service network-manager restart
- sudo apt-get install dnsmasq
- sudo vim /etc/dnsmasq.conf
- listen-address=127.0.0.1
- address=/dev/127.0.0.1
- address=/prod/127.0.0.1
- sudo service dnsmasq restart
Set up Apache for vhost_alias
mod_vhost_alias
# get the server name from the Host: header and put in %0
# this is for dev
RewriteCond %{HTTP_HOST} ^mongo.dev$
RewriteRule (.*) http://localhost:28017/_replSet
RewriteCond %{HTTP_HOST} ^mongo.snap$
RewriteRule (.*) http://192.168.1.100:28000/_replSet
UseCanonicalName Off
# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /var/www/vhosts/%0
<Directory />
# Global settings
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
- sudo a2enmod vhost_alias (this will enable module vhost_alias for loading).
- sudo vi /etc/apache2/mods-available/vhost_alias.conf (create one if not existing)
# get the server name from the Host: header and put in %0
# this is for dev
RewriteCond %{HTTP_HOST} ^mongo.dev$
RewriteRule (.*) http://localhost:28017/_replSet
RewriteCond %{HTTP_HOST} ^mongo.snap$
RewriteRule (.*) http://192.168.1.100:28000/_replSet
UseCanonicalName Off
# include the server name in the filenames used to satisfy requests
VirtualDocumentRoot /var/www/vhosts/%0
<Directory />
# Global settings
Options FollowSymLinks
AllowOverride All
</Directory>
</VirtualHost>
No comments:
Post a Comment