Я настроил Apache 2.4 на CentOS 7 в качестве обратного прокси-сервера с аутентификацией OAuth 2.0 с помощью Google. это мой http.conf файл:
ProxyRequests off
<Proxy *>
Order deny,allow
Deny from all
Allow from all
</Proxy>
ProxyTimeout 300
<VirtualHost test.mydomain.com:80>
ServerName test.mydomain.com
Redirect / https://test.mydomain.com/
</VirtualHost>
<VirtualHost test.mydomain.com:443>
ServerName test.mydomain.com
SSLEngine on
SSLCertificateFile /etc/httpd/ssl/mydomain.crt
SSLCertificateKeyFile /etc/httpd/ssl/mydomain.key
SSLCACertificateFile /etc/httpd/ssl/gd_bundle-g2-g1.crt
ErrorLog /var/www/html/test_error.log
CustomLog /var/www/html/test_access.log combined
OIDCProviderMetadataURL https://accounts.google.com/.well-known/openid-configuration
OIDCClientID xxxxxxxx-xxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com
OIDCClientSecret xxxxxxxxxxxxxxxxxxxxxxx
OIDCRedirectURI https://test.mydomain.com/index.php
OIDCScope "profile openid"
OIDCCryptoPassphrase example@3003
OIDCCookiePath /
OIDCAuthNHeader X-Forwarded-User
OIDCRemoteUserClaim sub
OIDCClaimPrefix example_
<Location />
AuthType openid-connect
Require valid-user
</Location>
ProxyPreserveHost On
ProxyPass / http://192.168.1.1:5563/
ProxyPassReverse / http://192.168.1.1:5563/
</VirtualHost>
Теперь, когда я набираю git https://test.mydomain.com, я перенаправляю в Google аутентификацию и после (если логин в порядке) к обратному ресурсу на http://192.168.1.1: 5563 /
Теперь я пытаюсь создать пользовательскую страницу входа в PHP, потому что я бы проверил, если пользователь может получить доступ (потому что с помощью Google OAuth могут получить доступ все члены домена) или нет к этому удаленному ресурсу http://192.168.1.1: 5563 / , и я создал свой индекс . php страница:
и test. php, которые я вызываю с помощью href:
<?php
session_start();
?>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>TEST</title>
<meta content='width=device-width, initial-scale=1, maximum-scale=1' name='viewport'/>
</head>
<body>
<?php
if(isset($_SESSION['logged']) && $_SESSION['logged']==true){
echo "<iframe width=\"100%\" height=\"100%\" src=\"https://test.mydomain.com/TEST\"></iframe>";
} else {
echo "<div class=\"container\">";
echo "<div class=\"frame\">";
echo "<div ng-app ng-init=\"checked = false\">";
echo "<h1><img align=\"center\" src=\"images/logo_rouded.png\" width=\"100\" height=\"auto\"></h1>";
echo "<form class=\"form-signin\" action=\"\" method=\"post\" name=\"form\">";
echo "<p align=\"center\">You are not login, please login</p>";
echo "<p align=\"center\">You'll redirect to login page in 5 seconds</p>";
header('Refresh: 5; url=index.php');
echo "</form>";
echo "</div>";
echo "</div>";
echo "</div>";
}
?>
</body>
</html>
И я изменил свой http.conf как ниже:
<VirtualHost test.mydomain.com:443>
ServerName test.mydomain.com
SSLEngine on
SSLCertificateFile /etc/httpd/ssl/mydomain.com.crt
SSLCertificateKeyFile /etc/httpd/ssl/mydomain.com.key
SSLCACertificateFile /etc/httpd/ssl/gd_bundle-g2-g1.crt
DocumentRoot /var/www/html/googleaccess/
DirectoryIndex index.php
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyRequests On
ProxyPass /TEST http://192.168.1.1:5563/ts/ts2/index.html
ProxyPassReverse /TEST http://192.168.1.1:5563/ts/ts2/index.html
</VirtualHost>
Теперь проблема в том, что: 1) обратный прокси не работает правильно (я думаю, что это неверная конфигурация в http.conf) 2) Если я наберу git https://test.mydomain.com/TEST Я прыгаю аутентификацию Google, как я могу заблокировать это? 3) Я не могу включить трафик c для всей сети в http://192.168.1.1: 5563 / ts / ts2 / index. html, по этой причине я должен использовать обратный прокси.
Спасибо за помощь