# SOGo Groupware
{
    $sogoStatus = $sogod{'status'} || "disabled";
    $webmailStatus = $imp{'status'} || "disabled";
    $activeSync = $sogod{'ActiveSync'} || 'disabled';
    $OUT = "";
}



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

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

{
if ($activeSync =~ m/^enabled|on|1|yes$/i){
    $OUT .=<<"HERE";
ProxyPass /Microsoft-Server-ActiveSync http://127.0.0.1:$sogod{'TCPPort'}/SOGo/Microsoft-Server-ActiveSync retry=60 connectiontimeout=5 timeout=3600
HERE
}
else {
    $OUT .= "# ActiveSync is disabled\n";
}
}

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

{
use Config;
my $arch = $Config{selectminbits};
 
    if ($arch eq "32"){
        $OUT .= qq(
        Alias /.woa/WebServerResources/ /usr/lib/GNUstep/SOGo/WebServerResources/
        Alias /SOGo.woa/WebServerResources/ /usr/lib/GNUstep/SOGo/WebServerResources/
        Alias /SOGo/WebServerResources/ /usr/lib/GNUstep/SOGo/WebServerResources/
        AliasMatch /SOGo/so/ControlPanel/Products/(.*)/Resources/(.*) /usr/lib/GNUstep/SOGo/\$1.SOGo/Resources/\$2\
  
<Directory "/usr/lib/GNUstep/SOGo/">
        );} 
    
    elsif ($arch eq "64"){
        $OUT .= qq(
        Alias /.woa/WebServerResources/ /usr/lib64/GNUstep/SOGo/WebServerResources/
        Alias /SOGo.woa/WebServerResources/ /usr/lib64/GNUstep/SOGo/WebServerResources/
        Alias /SOGo/WebServerResources/ /usr/lib64/GNUstep/SOGo/WebServerResources/
        AliasMatch /SOGo/so/ControlPanel/Products/(.*)/Resources/(.*) /usr/lib64/GNUstep/SOGo/\$1.SOGo/Resources\$2
    
<Directory "/usr/lib64/GNUstep/SOGo/">
        );}
}

    AllowOverride None
    Options +ExecCGI -Includes
#    Order allow,deny
#    Allow from all
     Require all granted
</Directory>

