crackhawk
Goto Top

Apache Document root auf anderen lokalen Webserver umleiten

Hallo Admins!

Ich habe derzeit zwei Debian Server Zuhause laufen. Auf dem einen (192.168.0.10) ist Apache2 als Webserver installiert, auf dem anderen (192.168.0.5) läuft eine Mailcow Instanz mit SOGo als E-Mail Server. Dessen Weboberfläche wird ebenfalls über Apache2 bereitgestellt.

Ich habe meine Fritz!Box so konfiguriert, dass HTTP und HTTPS Anfragen an den Webserver weitergeleitet werden. IMAP, POP3 und SMTP Anfragen werden an den E-Mail Server weitergeleitet.

Die Weboberfläche SOGo ist über den E-Mail Server Lokal unter http://192.168.0.5/SOGo/ erreichbar.

Auf dem Webserver habe ich verschiedene Virtual Hosts, unter anderem mail.domain.de, welche aus dem Internet erreichbar sind. Mein Plan ist nun, dass wenn ich auf mail.domain.de surfe, der Inhalt des Lokalen E-Mail Servers von http://192.168.0.5/SOGo/ angezeigt wird.

Ich habe bereits mit diversen ReverseProxy Einträgen in den Virtual Host *.conf Dateien rumgespielt, jedoch ohne Erfolg.

Wie stelle ich das an?

Beste Grüße,
Daniel

Content-Key: 328886

Url: https://administrator.de/contentid/328886

Printed on: April 24, 2024 at 02:04 o'clock

Member: em-pie
em-pie Feb 08, 2017 at 19:47:04 (UTC)
Goto Top
Moin,

Variante 1 wäre, sofern möglich, den Port der SOGo von Port 80 auf z.B. 9980 zu ändern und diesen in der FritzBox freizugeben.
Variante 2 wäre u.U. mit iFrames auf dem 0.10er zu arbeiten. ich weiss aber nicht, ob das wirklich sauber funktioniert. Das schoß mir als erstes nur in den Kopf

Vermutlich gibt es auch noch Varianten >2, aber die fallen mir spontan nicht ein

Du solltest dir aber noch überlegen,ob du den Traffic des SOGos nicht irgendwie noch mit https aufgerufen bekommst, denn das macht das ganze etwas sicherer...

Gruß
em-pie
Member: BirdyB
BirdyB Feb 08, 2017 at 20:32:59 (UTC)
Goto Top
Ich befürchte, du hast bei deinen Reverse-Proxy-Einträgen etwas falsch gemacht...
Zeig uns doch mal die entsprechende Config...
Member: crackhawk
crackhawk Feb 09, 2017 updated at 16:09:41 (UTC)
Goto Top
Hi, anbei meine mail.domain.de.conf und mail.domain.de-le-ssl.conf.

Zuerst die Originale:

mail.domain.de.conf:
<VirtualHost *:80>
        ServerAdmin     admin@domain.de
        ServerName      mail.domain.de
        DocumentRoot    /var/www/mail.domain.de/
        ErrorLog        ${APACHE_LOG_DIR}/error.log
        CustomLog       ${APACHE_LOG_DIR}/access.log combined
RewriteEngine on
RewriteCond %{SERVER_NAME} =mail.domain.de
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,QSA,R=permanent]
</VirtualHost>

mail.domain.de-le-ssl.conf:
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin     admin@domain.de
        ServerName      mail.domain.de
    	DocumentRoot    /var/www/mail.domain.de/
        ErrorLog        ${APACHE_LOG_DIR}/error.log
        CustomLog       ${APACHE_LOG_DIR}/access.log combined
SSLCertificateFile /etc/letsencrypt/live/mail.domain.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mail.domain.de/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

Die mail.domain.de.conf habe ich immer so belassen, da sie (soweit ich das verstehe) nur auf die mail.domain.de-le-ssl.conf umleitet.

Versucht habe ich es mit folgenden varianten in der mail.domain.de-le-ssl.conf:
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin     admin@domain.de
        ServerName      mail.domain.de
    	DocumentRoot    /var/www/mail.domain.de/
        ErrorLog        ${APACHE_LOG_DIR}/error.log
        CustomLog       ${APACHE_LOG_DIR}/access.log combined

<Location />
      ProxyPass http://192.168.0.5/SOGo
      ProxyPassReverse http://192.168.0.5/SOGo
 </Location>

SSLCertificateFile /etc/letsencrypt/live/mail.domain.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mail.domain.de/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

sowie:
<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerAdmin     admin@domain.de
        ServerName      mail.domain.de
    	DocumentRoot    /var/www/mail.domain.de/
        ErrorLog        ${APACHE_LOG_DIR}/error.log
        CustomLog       ${APACHE_LOG_DIR}/access.log combined

ProxyPass "/var/www/mail.domain.de/" "http://192.168.0.5/SOGo/"  
ProxyPassReverse "/var/www/mail.domain.de/" "http://192.168.0.5/SOGo/"  

SSLCertificateFile /etc/letsencrypt/live/mail.domain.de/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/mail.domain.de/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

Bei der ersten Variante werde ich auf http://192.168.0.5/SOGo weitergeleitet, was natürlich nur lokal funktioniert.
Bei der zweiten Variante lande ich in einer Endlosschleife: https://mail.domain.de/SOGo/SOGo/SOGo/SOGo/SOGo/...usw.
Letzteres sieht für mich somit vielversprechender aus.

Mit iFrames arbeiten möchte ich nicht. Ich denke auch, wenn ich Daten eines anderen lokalen Servers per iFrame einbinden kann, muss es auch möglich sein einfach auf dessen Document Root zuzugreifen.

Mit einem anderen Port müsste ich ja auf IP Ebene arbeiten - auch nicht so toll face-confused

Auf meinem Webserver habe ich Let's Encrypt eingerichtet. HTTP leitet automatisch auf HTTPS um. Eine unverschlüsselte Verbindung möchte ich natürlich nicht face-smile

Vielen Dank und Grüße
Member: Sheogorath
Solution Sheogorath Feb 10, 2017 updated at 14:18:33 (UTC)
Goto Top
Moin,

Ich lese sogo und dachte mir nun einfach mal, ich teile dir meine ganze apache2 config für Sogo mal mit ;)

Ist so tatsächlich produktiv, wenn auch etwas unübersichtlich und gefrickelt:

`cat /path/to/config/myconf.conf | sed -e 's/mydomain/example/'`

<VirtualHost *:80>
        ServerName mail.example.com
        RewriteEngine On
        RewriteRule ^/.* https://mail.example.com/SOGo
        #Redirect permanent / https:{{comment_single_line_double_slash:0}}
</VirtualHost>

<IfModule mod_ssl.c>
<VirtualHost *:443>
       ServerName mail.example.com
       DocumentRoot /var/www/vsites/mail.example.com
       Header always set Strict-Transport-Security "max-age=63072000; includeSubDomains; preload"  

       RewriteEngine On
       RewriteRule ^/$ https://mail.example.com/SOGo
       ErrorLog ${APACHE_LOG_DIR}/error.log

        # Possible values include: debug, info, notice, warn, error, crit,
        # alert, emerg.
        LogLevel warn

        CustomLog ${APACHE_LOG_DIR}/ssl_access.log combined

        #   SSL Engine Switch:
        #   Enable/Disable SSL for this virtual host.
        SSLEngine on

        #   A self-signed (snakeoil) certificate can be created by installing
        #   the ssl-cert package. See
        #   /usr/share/doc/apache2.2-common/README.Debian.gz for more info.
        #   If both key and certificate are stored in the same file, only the
        #   SSLCertificateFile directive is needed.
        SSLCertificateFile    /etc/letsencrypt/live/mail.example.com-0001/fullchain.pem
        SSLCertificateKeyFile /etc/letsencrypt/live/mail.example.com-0001/privkey.pem

Alias /SOGo.woa/WebServerResources/ \
      /usr/lib/GNUstep/SOGo/WebServerResources/
Alias /SOGo/WebServerResources/ \
      /usr/lib/GNUstep/SOGo/WebServerResources/

<Directory /usr/lib/GNUstep/SOGo/>
    AllowOverride None

    <IfVersion < 2.4>
        Order deny,allow
        Allow from all
    </IfVersion>
    <IfVersion >= 2.4>
        Require all granted
    </IfVersion>

    # Explicitly allow caching of static content to avoid browser specific behavior.
    # A resource's URL MUST change in order to have the client load the new version. 
    <IfModule expires_module>
      ExpiresActive On
      ExpiresDefault "access plus 1 year"  
    </IfModule>
</Directory>

## Uncomment the following to enable proxy-side authentication, you will then
## need to set the "SOGoTrustProxyAuthentication" SOGo user default to YES and 
## adjust the "x-webobjects-remote-user" proxy header in the "Proxy" section 
## below.
#
## For full proxy-side authentication:
#<Location /SOGo>
#  AuthType XXX
#  Require valid-user
#  SetEnv proxy-nokeepalive 1
#  Allow from all
#</Location>
#
## For proxy-side authentication only for CardDAV and GroupDAV from external
## clients:
#<Location /SOGo/dav>
#  AuthType XXX
#  Require valid-user
#  SetEnv proxy-nokeepalive 1
#  Allow from all
#</Location>

ProxyRequests Off
SetEnv proxy-nokeepalive 1
ProxyPreserveHost On

# When using CAS, you should uncomment this and install cas-proxy-validate.py
# in /usr/lib/cgi-bin to reduce server overloading
#
# ProxyPass /SOGo/casProxy http://localhost/cgi-bin/cas-proxy-validate.py
# <Proxy http://localhost/app/cas-proxy-validate.py>
#   Order deny,allow
#   Allow from your-cas-host-addr
# </Proxy>
ProxyPass /SOGo http://127.0.0.1:20000/SOGo retry=0

# Enable to use Microsoft ActiveSync support
# Note that you MUST have many sogod workers to use ActiveSync.
# See the SOGo Installation and Configuration guide for more details.
#
ProxyPass /Microsoft-Server-ActiveSync \
 http://127.0.0.1:20000/SOGo/Microsoft-Server-ActiveSync \
 retry=60 connectiontimeout=5 timeout=360

<Proxy http://127.0.0.1:20000/SOGo>
## adjust the following to your configuration
  RequestHeader set "x-webobjects-server-port" "443"  
  RequestHeader set "x-webobjects-server-name" "example.com"  
  RequestHeader set "x-webobjects-server-url" "https://mail.example.com"  

## When using proxy-side autentication, you need to uncomment and
## adjust the following line:
  RequestHeader unset "x-webobjects-remote-user"  
#  RequestHeader set "x-webobjects-remote-user" "%{REMOTE_USER}e" env=REMOTE_USER  

  RequestHeader set "x-webobjects-server-protocol" "HTTP/1.0"  

  AddDefaultCharset UTF-8

  Order allow,deny
  Allow from all
</Proxy>

# For Apple autoconfiguration
<IfModule rewrite_module>
  RewriteEngine On
  RewriteRule ^/.well-known/caldav/?$ /SOGo/dav [R=301]
  RewriteRule ^/.well-known/carddav/?$ /SOGo/dav [R=301]
</IfModule>

        BrowserMatch "MSIE [2-6]" \  
                nokeepalive ssl-unclean-shutdown \
                downgrade-1.0 force-response-1.0
        # MSIE 7 and newer should be able to use keepalive
        BrowserMatch "MSIE [17-9]" ssl-unclean-shutdown  

</VirtualHost>
</IfModule>

Ich denke mal, das wird dir ziemlich weiterhelfen.

Für den Let's Encrypt/Certbot Setup empfehle ich: https://www.shivering-isles.com/lets-encrypt-renew-all-your-certs-using- ...

Im Artikel einfach den letsencrypt client durch certbot ersetzen.

Edit: Mir fällt gerade auf, ich sollte dringend mal meine configs neu formatieren :D

Gruß
Chris