MacBook avec code sur un bureau

PHP – NGINX: How to pass the PHP_AUTH_USER and PHP_AUTH_PW variables

In the Nginx configuration, just add the configuration

fastcgi_param HTTP_AUTHORIZATION $http_authorization if_not_empty;

so that the authentication variables are filled in.

On the PHP side, to retrieve them

$username = $_SERVER['PHP_AUTH_USER'];
$password = $_SERVER['PHP_AUTH_PW'];