I want to authorize the consultation of directories hosted on Apache 2.4 and limit the downloading of files to only authenticated users.
The files are very large and cannot be downloaded via scripting language due to memory limitation.
Is there an alternative of the Nginx ngx_http_auth_request_module module on Apache?
I want to migrate my Nginx web server to Apache 2.4, here is the solution I am currently using on Nginx:
Nginx configuration
location ~ .+(?<!/)$
{
auth_request /auth.php;
error_page 401 = @login;
}
location @login
{
internal;
return 302 /account/login.php;
}
auth.php
ob_start();
session_start();
if( isset($_SESSION['logged_in']) && $_SESSION['logged_in'] == true ) {
header("HTTP/1.1 200 OK");
} else {
header("HTTP/1.1 401 Unauthorized");
}