skip to Main Content

Let’s say there are 4 users on my local machine all with the same IP by the name of “Chris”, “James”, “Ben”, and “Charles”. If I have a website on Apache, if any of them were to type in “localhost” into search they would be able to see that website.

How would I make it so say “Charles” cannot access the website? So if he were to type in “localhost” or the IP address he would be denied from the server any access to that particular website.

2

Answers


  1. You can create a .htaccess file to specify user authentication. This way only authenticated users have access to the web server.

    Here is a tutorial:
    https://www.digitalocean.com/community/tutorials/how-to-set-up-password-authentication-with-apache-on-ubuntu-14-04

    Login or Signup to reply.
  2. If users are logged in locally, you may use iptables to block specific user. Please try the command below:

    $ sudo iptables -A OUTPUT -o EXTERNAL_IF -m owner –uid-owner USERNAME -d DESTINATION_WEB -j REJECT

    Where:

    EXTERNAL_IF is the name of the Internet-bound interface (e.g. eth0)

    USERNAME is the login id of the restricted user

    DESTINATION_WEB is the DNS name or IP address of the destination website. Beware of sites that host many websites (such as blogger) or those that have multiple public IPs (such as Google)

    Hope this information works for you.

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search