Ubuntu – Disable public access to the apache2 server

Apache2webserver

I've just installed apache2 on my Ubuntu 14.04

My server is now accessible from anywhere if the right IP was provided. I want to disable that so that only users within my local network would be able to access the server.

I presume it has to be done from apache2.conf

P.S. I am sure this question has been asked before, but I think I lack the correct keywords to find a previous post 🙂

Best Answer

Maybe is better to enable firewall? UFW can allow access from host/network and deny for the rest of the world.

sudo ufw enable
sudo ufw allow from xxx.xxx.xxx.xxx/zz to any port 80 proto tcp

xxx.xxx.xxx.xxx - represent your local network, zz reprezent network mask

You can list rules with command

sudo ufw status

or

sudo ufw status numbered