I have a webserver on my RaspberryPi with apache2. I can browse the website with pi's local IP address like 192.168.x.x. I want to browse it without IP in my LAN like, http://local.mypi.com.
How can I do it? Thanks
I have a webserver on my RaspberryPi with apache2. I can browse the website with pi's local IP address like 192.168.x.x. I want to browse it without IP in my LAN like, http://local.mypi.com.
How can I do it? Thanks
In order to browse by domain name rather then IP address, 2 things need to happen -
(I've not discussed HTTPS here, as this would seem entirely impractical).
Resolving the domain name
How you resolve the domain name will depend on your setup. The easiest way is to modify the "hosts" file on the computers that will need to access the site. (Almost all OS's have a hosts file). You need administrator privileges, and add a line like
192.168.x.x local.mypi.com
There are other ways to achieve this, however they are dependent on the network and devices. Sometimes (rarely) you can assign computer names on the router, and on more advanced routers you can sometimes modify the DNS configuration.
Another solution would be to run a DNS server on the Pi. The problem with this is that you will need to get clients to use the Pi's DNS server, and this could mean running a DHCP server and disabling the one on the router.
If you are only looking at Linux and Mac devices (ie not Windows), you may be able to use a "Zeroconf" implentation on your Pi. Configuring the web server
There are 2 modes for HTTP on Apache - name based and IP based. If you use IP based configuration you can only run set of websites. Name based virtual hosting will allow you to run multiple websites, but you will need to specify a different config for each. Name based virtual hosting is more common.
If you are using IP based virtual hosting you don't need to worry about domain to IP address mapping on the server - the server does not care about the domain name used.
If you are using name based virtual hosting you will need to add configuration for your domain name like the following to your apache config
<VirtualHost *:80>
ServerName local.mypi.com
DocumentRoot "/path/to/websitefiles"
</VirtualHost>