Ubuntu: How can ensure that my LAMP server isn't avilable for online access?



Question:

I'm currently using LAMP (MySQl + PhP + PhpMyAdmin) for web development class, but I'm kinda scared that someone could access to my data trough it.

How can i ensure that my server isn't available to the public? i want it only for me, i don't want to share it over the net or the Internet.

I'm currently using Ubuntu 14.04.5

I'm using Apache 2.4, PHP5.


Solution:1

Will you only be accessing it locally via the localhost address?

You could use iptables firewall to allow only outgoing connections from your computer (and incoming traffic related to that):

iptables -I OUTPUT -o eth0 -d 0.0.0.0/0 -j ACCEPT  iptables -I INPUT -i eth0 -m state --state ESTABLISHED,RELATED -j ACCEPT  

where eth0 would be your network interface (could be wlan0 in case you're using a wireless, check with ifconfig).


Solution:2

You can simply deny except your local network and localhost

sudo vi /etc/apache2/apache2.conf

In there you need to add/change

<Directory /var/www/html/>    Order allow,deny    Allow from YOUR_LOCAL_NETWORK     Allow from 127  </Directory>  

YOUR_LOCAL_NETWORK could be 192.168.1.0/24

Everything else will be denied by default.

After you changed the file you need to restart apache

sudo service apache2 restart


Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Previous
Next Post »