Apache 2 als reverse Proxy mit externen Authorisierungsscript

Servername intern: hide.int.lan

Servername zur Welt: show.ext.lan

Umleiten der unverschluesselten Anfragen

Es soll auf jeden Fall nur Verschluesselt von der Welt auf show.ext.lan zugegriffen werden, deshalb werden anfragen auf dem normalen http Port umgeleitet.

Listen  192.168.55.13:80
<VirtualHost 192.168.55.13:80>
  ServerAdmin admin@ext.lan
  ServerName show.ext.lan
  DocumentRoot "/home/www/show/html-data"
  ErrorLog /home/www/show/log/httpd-error.log
  CustomLog /home/www/show/log/httpd-access.log combined
  #Alle zugriffe sollen auf SSL laufen!
  RewriteEngine On
  RewriteRule ^/(.*)$ https://%{SERVER_NAME}/$1 [R,L]
</VirtualHost>

.

der reverse Proxy

Listen  192.168.55.13:443
<VirtualHost 192.168.55.13:443>
  #SSL OPTIONEN
  SSLEngine on
  SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP
  SSLCertificateFile /home/www/show/ssl/show.ext.lan.crt
  SSLCertificateKeyFile /home/www/show/ssl/show.ext.lan.key
  SSLOptions +OptRenegotiate
  <IfModule mod_proxy.c>
    SSLProxyEngine On
    ProxyPreserveHost On
    ProxyRequests Off
    ProxyVia On
  </IfModule>
  #external script auth show
  AddExternalAuth show_auth /home/foo/bin/script-auth.pl
  SetExternalAuthMethod show_auth pipe
  ServerAdmin network-support@ext.lan
  ServerName show-proxy.int.lan
  DocumentRoot "/home/www/show/html-data"
  ErrorLog /home/www/show/log/httpd-error.log
  CustomLog /home/www/show/log/httpd-access.log combined
  CustomLog /home/www/show/log/welf-access.log welf-http
  RewriteEngine On
  RewriteCond %{REQUEST_URI} ^/(?!error-documents)
  RewriteRule ^/(.*) http://hide.int.lan/$1 [P,L]
  <Location ~  "^/(?!error-documents)">
    Order deny,allow
    Allow from all
    AuthType Basic
    AuthName "Authentication"
    AuthExternal show_auth
    require valid-user
  </Location>
  <LocationMatch "^/error-documents">
    Order deny,allow
    Allow from all
  </LocationMatch>
  ErrorDocument 401 /error-documents/error401.html
</VirtualHost>

.

ProxyPass innerhalb von Location wird zwar in der Apachen Dokumentation so beschrieben ist aber wohl seit laengeren kaputt.

Eigentlich sollte ProxyPass...

  <Location ~  "^/(?!error-documents)">
    ProxyPass  http://hide.int.lan:80/
    ProxyPassReverse http://hide.int.lan:80/
  </Location>

.

...innerhalb von Location Tags funktionieren. Deshalb verwende ich das onehin viel flexiblere mod_rewrite zusammen mit mod_proxy.

  RewriteCond %{REQUEST_URI} ^/(?!error-documents)
  RewriteRule ^/(.*) http://hide.int.lan/$1 [P,L]

.

in meinem Fall verwende ich /error-documents/ als localen Content das laesst sich natuerlich auch erweitern z.B. mit ^/(?!error-documents|public) als RegExp.

Apache/ReverseProxy (last edited 2008-07-14 09:55:40 by localhost)