A server is setup on local lan which acts as a development server, backup server, a secure domain to manage database servers and host other important data on local lan. The setup is same for a valid FQDN which can be accessed from WAN.
Server : Ubuntu 18.04 LTSApplication server : LAMP stackMain site path : /var/www/htmldomain name : myserver.lanVirtual host path : /var/www/vhostsdomain name1 : your domain name.
Example : dev.myserve.lan
domain name2 : your domain name.
Example : secure.myserver.lan
- Create config files for vhosts
run command :
cd /etc/apache2/sites-availablesudo cp 000-default.conf dev-myserver-lan.confsudo cp 000-default.conf secure-myserver-lan.conf
- Edit config files:
sudo nano /etc/apache2/sites-available/secure-myserver-lan.conf
# Note: you can add ip as <VirtualHost 192.168.1.1:80> to respond to a specific ip.
<VirtualHost *:80>ServerName secure.myserver.lan#ServerAlias www.myserver.lanServerAdmin secure_myserver_lan@localhostDocumentRoot /var/www/secure# This site can be accessed from local lan and ip range (192.168.*.*) only<Directory /var/www/secure/>require host localhostrequire ip 127.0.0.1require ip 192.168</Directory>
# very important set logs for each site (personal preference)
ErrorLog ${APACHE_LOG_DIR}/secire_myserver_lan-error.log
CustomLog ${APACHE_LOG_DIR}/secure_myserver_lan-access.log combined
<VirtualHost>
- Enable virtual host
# sudo a2ensite your-domain-conf
sudo a2ensite secure-myserver-lan.confsudo systemctl restart apache2
- Disable virtualhost
# sudo a2ensite your-domain-conf
sudo a2dissite secure-myserver-lan.confsudo systemctl restart apache2
- Routing : If the domains are on local lan, you can forward the requests from your router or add to local host file
sudo nano /etc/hosts[...]192.168.1.251 secure.myserver.lan192.168.1.251 dev.myserver.lan[...]
- To access the site from a browser use the http or https tag without fail or you may be redirected to websearch
Browser address barWrong : dev.myserver.lan
Right : http://dev.myserver.lan
Right : https://dev.myserver.lan
No comments:
Post a Comment