-6

I need a solution, how to make a web application hosted in web server can be accessible to certain computer machines using PHP language or Java. I need to restrict a web application to certain computer machines. So please tell me how it can achieved??

  • 1
    How do you want to enforce the access? Based on IP address? Based on hostname? Based on MAC address? Please be more specific. – Oldskool Apr 15 '16 at 09:13
  • Possible duplicate of [htaccess - using password OR ip whitelist](http://stackoverflow.com/questions/7667004/htaccess-using-password-or-ip-whitelist) – Sony Mathew Apr 15 '16 at 09:34
  • @old school, Based on MAC Address i need to restrict it.How do it get MAC address of client machine from server. – praveen kotekar Apr 15 '16 at 09:50
  • @praveenkotekar PHP can only do that in very specific circumstances, see: http://stackoverflow.com/q/1420381/214577 If that doesn't work for you, you should probably cook something up in Java. – Oldskool Apr 15 '16 at 09:52

3 Answers3

1

Basically you have several options. You could secure your application using apache authentication which requires user to insert username and password. You could restrict access to the application using IP address or implement the authentication on the application layer.

I do not suggest using IP authentication tho, because it simply isn't secure.

Apache authentication: apache documentation

PHP Authentication: PHP Documentation

Lauri Orgla
  • 542
  • 3
  • 10
1

If you are using apache web server then you can restrict certain IPs in webserver configuration itself as suggested here.

This is not only in Apache but any webserver out there, you can do the same thing but configuration style differs.

Community
  • 1
  • 1
kakurala
  • 762
  • 5
  • 15
0

You make a whitelist of IP addresses that are allowed to connect to the web server.

Then you can get the client's IP addresses in PHP:

$userIpAddress = $_SERVER['REMOTE_ADDR'];

or in Java:

String userIpAddress = request.getHeader("Remote_Addr");

Note that getting the real IP address of the user can be tricky. See these questions:

The easiest way, though, would be to restrict clients' access directly in the webserver configuration.

Community
  • 1
  • 1
dr_
  • 2,129
  • 1
  • 20
  • 32