# SOGo Groupware
{
    $sogoStatus = $sogod{'status'} || "disabled";
    $webmailStatus = $imp{'status'} || "disabled";
    my $lib = ( -d '/usr/lib64/GNUstep/SOGo/WebServerResources' ) ? 'lib64':'lib';
    $style = $sogod{'WebServerResources'} || '/usr/' . $lib . '/GNUstep/SOGo/WebServerResources/';
    $style = '/usr/' . $lib . '/GNUstep/SOGo/WebServerResources/' unless ( -d $style);
    $style =~ s#$#/# unless ( $style =~ m#/$# );

    $OUT = "";
}

ScriptAlias /sogo-cgi-bin /usr/share/SOGo/cgi-bin
<Directory /usr/share/SOGo/cgi-bin>
    AllowOverride None
    Options +ExecCGI
    Order deny,allow
    Allow from 127.0.0.1
</Directory>

ProxyPass /SOGo/casProxy http://localhost/sogo-cgi-bin/cas-proxy-validate

ProxyPass /SOGo http://127.0.0.1:{$sogod{'TCPPort'}}/SOGo
ProxyPassReverse /SOGo http://127.0.0.1:{$sogod{'TCPPort'}}/SOGo
SetEnvIf Host (.*) REQUEST_HOST=$1

# iOS auto discovery
RedirectMatch ^/principals/users/(.*)$ /SOGo/dav/$1
RedirectMatch ^/principals/$ /SOGo/dav/
RedirectMatch ^/.well-known/(caldav|carddav)$ /SOGo/dav/

<Location /SOGo>
    order deny,allow
    deny from all
    allow from all
    SSLRequireSSL on
    AddDefaultCharset UTF-8
    RequestHeader set "x-webobjects-server-url" "https://%\{REQUEST_HOST\}e/SOGo"
</Location>

<Location /SOGo/casProxy>
    Order deny,allow
    Deny from All
    Allow from 127.0.0.1 {"$LocalIP";}
</Location>

Alias /.woa/WebServerResources/ {"$style";}
Alias /SOGo.woa/WebServerResources/ {"$style";}
Alias /SOGo/WebServerResources/ {"$style";}
AliasMatch /SOGo/so/ControlPanel/Products/(.*)/Resources/(.*) /usr/{$lib}/GNUstep/SOGo/$1.SOGo/Resources/$2

<Directory {"\"$style\"";}>
    AllowOverride None
    Options +ExecCGI -Includes
    Order allow,deny
    Allow from all
</Directory>

