yum -y install httpd yum -y install mod_ssl yum -y install php yum -y install mcStartujemy Apache wraz z ustawieniem autostartu serwisu:
systemctl enable httpd.service systemctl start httpd.serviceDo /var/www/html/ wrzucami przykładową stronę w php:
<?php phpinfo(); ?>Proponuje, zainstalować certyfikat SSL testowy z wykorzystaniem narzędzia http://ssl4ip.westeurope.cloudapp.azure.com/ oraz DigiCert Util, aby wyeksportować .pfx do .cer i .key. Wstawiamy certyfikat dla naszej strony, a następnie w tym samym pliku pośrednie centrum certyfikacji i klucz prywatny do odpowiednich plików:
vi /etc/pki/tls/private/localhost.key vi /etc/pki/tls/certs/localhost.crt service httpd restartNa pierwsze testy włączamy uwierzytelnianie Basic:
cd /var/www/html touch .htpasswd htpasswd .htpasswd a I podajemy hasło np. aKreujemy plik .htaccess:
vi /var/www/html/.htpasswdo treści:
AuthType Basic AuthName “Azure Active Directory” AuthUserFile /var/www/html/.htpasswd Require valid-userJeszcze musimy prze-konfigurować Apache, aby akceptował nadpisywanie zmian z plików .htaccess:
vi /etc/httpd/conf/httpd.confi zmieniamy wszędzie z AllowOverride none na AllowOverride All, a na koniec restartujemy Apache:
service httpd restartOd tego momentu powinniśmy wejść na stronę np.: https://213-199-133-54.h.com.pl, gdzie 213.199.133.54 to ip naszego serwera z Apache – wykorzystujemy DNS i certyfikat z http://ssl4ip.westeurope.cloudapp.azure.com/. Po podaniu loginu ja hasła powinniśmy dostać się do strony. To teraz trzeba prze-konfigurować funkcjonalność, tak aby do tego celu wykorzystywać Azure Active Directory. Instalujemy pakiet mod_auth_openidc:
yum install mod_auth_openidc repoquery -l mod_auth_openidcw pliku (vi /etc/httpd/conf.d/auth_openidc.conf) dodajemy:
OIDCProviderMetadataURL https://login.microsoftonline.com/2f5c0b12-3c26-4d04-9c4f-22b2dc35c /v2.0/.well-known/openid-configuration # OIDCRedirectURI is a vanity URL that must point to a path protected by this module but must NOT point to any content OIDCRedirectURI https://213-199-133-54.h.com.pl/a OIDCCryptoPassphrase random1234 OIDCClientID 5ed1690e-b7d1-48b8-9eae-bcad7ddad OIDCClientSecret WGxILH2Rk2IgTx5YwYHH7Sxpit4yrUDTQ=Gdzie:
2f5c0b12-3c26-4d04-9c4f-22b2dc35c – Id Tenant’u Azure Active Directory https://213-199-133-54.h.com.pl/a – przekierowanie po powrocie – katalog, a nie musi istnieć, ale tutaj wrócimy np. z błędem uwierzytelnienia 5ed1690e-b7d1-48b8-9eae-bcad7ddad – Id Aplikacji z Azure Active Directory WGxILH2Rk2IgTx5YwYHH7Sxpit4yrUDTQ= – secret – dodany w portalu w danej aplikacji.Na zakończenie zmieniamy /var/www/html/.htaccess na:
AuthType openid-connect Require valid-userI wydajemy service httpd restart i uwierzytelnianie z wykorzystaniem Azure Active Directory już działa. Możemy skonfigurować, że użytkownik musi mieć nadane uprawnienia, aby skorzystać z danej aplikacji. Być może wkrótce Video Step by Step jak to wszystko zrobić, gdyż jeden obraz mówi więcej niż tysiące słów – a co dopiero Video.
Recently, I have to configure authentication using Azure Active Directory in Apache. How to do it using CentOs 7.5 using OpenID / Oauth. First step is to install Apache and some other components:
yum -y install httpd yum -y install mod_ssl yum -y install php yum -y install mcStart Apache and set it to autostart:
systemctl enable httpd.service systemctl start httpd.servicePut to /var/www/html/ sample webpage:
<?php phpinfo(); ?>I suggest installing a test SSL certificate using the tool from http://ssl4ip.westeurope.cloudapp.azure.com/ and DigiCert Util to export .pfx to .cer / .key. We insert the certificate for our site and then in the same file the intermediate certificate and the private key to the appropriate files::
vi /etc/pki/tls/private/localhost.key vi /etc/pki/tls/certs/localhost.crt service httpd restartAt the beginning lets test with Basic Authentication:
cd /var/www/html touch .htpasswd htpasswd .htpasswd aand provide password. Please create .htaccess file:
vi /var/www/html/.htpasswdwith:
AuthType Basic AuthName “Azure Active Directory” AuthUserFile /var/www/html/.htpasswd Require valid-userPlease reconfigure Apache:
vi /etc/httpd/conf/httpd.confreplace everywhere from AllowOverride none to AllowOverride All, and restart Apache:
service httpd restartFrom that moment, we should go to the site, for example: https://213-199-133-54.h.com.pl, where 213.199.133.54 is the IP of our server with Apache – we use DNS and the certificate from http: // ssl4ip. westeurope.cloudapp.azure.com/. After entering the login password, we should get to the site. It is now necessary to reconfigure the functionality so that Azure Active Directory can be used for this purpose. Please install mod_auth_openidc:
yum install mod_auth_openidc repoquery -l mod_auth_openidcAdd to /etc/httpd/conf.d/auth_openidc.conf:
OIDCProviderMetadataURL https://login.microsoftonline.com/2f5c0b12-3c26-4d04-9c4f-22b2dc35c /v2.0/.well-known/openid-configuration # OIDCRedirectURI is a vanity URL that must point to a path protected by this module but must NOT point to any content OIDCRedirectURI https://213-199-133-54.h.com.pl/a OIDCCryptoPassphrase random1234 OIDCClientID 5ed1690e-b7d1-48b8-9eae-bcad7ddad OIDCClientSecret WGxILH2Rk2IgTx5YwYHH7Sxpit4yrUDTQ=Where:
2f5c0b12-3c26-4d04-9c4f-22b2dc35c – Azure Azctive Directory Tenant ID https://213-199-133-54.h.com.pl/a – redirection on the return – a directory, does not have to exist, but here we will return, eg with an authentication error 5ed1690e-b7d1-48b8-9eae-bcad7ddad – Application ID from Azure Active Directory WGxILH2Rk2IgTx5YwYHH7Sxpit4yrUDTQ= – secret – added in the portal in the given application.Modify /var/www/html/.htaccess to:
AuthType openid-connect Require valid-userAnd we release service httpd restart and authentication using Azure Active Directory is already working. We can configure that the user must be granted permission to use the application. Maybe soon I will record Step by Step Video how to do it.
Some screenshot / Kilka obrazków poglądowych: