1

Is it possible to have authentication in Apache (or for example Nginx/HAProxy/etc) with a PHP file? What I want is the following:

  1. User visits a portal (index.php).
  2. Apache will look if index.php gives the HTTP status code 200 OK or 401 Unauthorized (the PHP file checks if a user is logged in and sends a custom header).
  3. When a 200 OK is given, the user may enter the portal. If the index.php is giving a 401 HTTP status code, the user needs to login.

Everything needs to happen within the index.php file and needs to work at the Apache layer.

The authentication proces in the PHP file I made does exactly what I need, but now I want to connect this with Apache in one way or another. Hopefully my explanation is clear.

I want this because of the following reason: I've built a portal to visit some apps (Owncloud, Munin, Wiki, Shell in a Box). This portal is a proxy server and when you visit for example www.example.com/owncloud, you get proxied to the Owncloud server/container. Currently I've a htpasswd solution, but I want a custom authentication page (to control the authenticate proces).

0

You must log in to answer this question.

Browse other questions tagged .