## Common configuration for OBM and LL::NG

# Security
ServerSignature Off

# Load LemonLDAP::NG Handler
PerlOptions +GlobalRequest
PerlRequire /var/lib/lemonldap-ng/handler/MyHandler.pm

# Error documents
ErrorDocument 403 https://srv-obm.mairie.bress/sso/portal/?lmError=403
ErrorDocument 500 https://srv-obm.mairie.bress/sso/portal/?lmError=500

# Perl preloading
<Perl>
    require Lemonldap::NG::Portal::SharedConf;
    Lemonldap::NG::Portal::SharedConf->compile(
    qw(delete header cache read_from_client cookie redirect unescapeHTML));
    # Uncomment this line if you use Lemonldap::NG menu
    require Lemonldap::NG::Portal::Menu;
    # Uncomment this line if you use portal SOAP capabilities
    #require SOAP::Lite;
</Perl>

# SSL vhosts
NameVirtualHost *:443
<VirtualHost *:443>
    ServerAdmin root@localhost
    DocumentRoot /usr/share/obm/www/php
    ServerName srv-obm.mairie.bress

    Timeout 3000
   
    # SSL
    SSLEngine on
    SSLCACertificateFile /var/lib/obm-ca/cacert.pem
    SSLCertificateFile /etc/obm/certs/obm_cert.pem
    SSLVerifyClient none
    SetEnvIf User-Agent ".*MSIE.*" nokeepalive ssl-unclean-shutdown downgrade-1.0 force-response-1.0

    ErrorLog /var/log/apache2/obm-error.log
    CustomLog /var/log/apache2/obm-access.log common
    SetEnv OBM_INCLUDE_VAR obminclude
    Alias /images /usr/share/obm/www/resources
    #OBM 2.2.x use utf8
    #AddDefaultCharset ISO-8859-15
    DirectoryIndex obm.php
    Options -Indexes

    php_value include_path  ".:/usr/share/obm/www"
    php_value session.bug_compat_42  0
    php_value session.bug_compat_warn  0
#    php_value session.gc_maxlifetime 2880
    php_value magic_quotes_gpc  Off
    php_value memory_limit 128M
    php_value post_max_size 10M
    php_value log_errors Off

    # turn this On to see debug messages
    php_value display_errors Off

    # 6135 = E_ALL & ~E_NOTICE => debug configuration
    php_value error_reporting 6135
    php_value upload_max_filesize 10M

    LimitRequestBody 20971520

    Alias /stats /var/www/munin

    <Location ~ "#/autodiscover#i">
        Order Allow,Deny
        Allow from All
        ProxyPass http://127.0.0.1:8080/opush/Autodiscover/
        ProxyPassReverse http://127.0.0.1:8080/opush/Autodiscover/
        PerlHeaderParserHandler My::Package->unprotect
    </Location>

    <Location /obm-sync>
        Order Allow,Deny
        Allow from All
        ProxyPass http://127.0.0.1:8080/obm-sync
        ProxyPassReverse http://127.0.0.1:8080/obm-sync
        PerlHeaderParserHandler My::Package->unprotect
    </Location>

    <Location /funambol>
        Order Allow,Deny
        Allow from All
        ProxyPass http://127.0.0.1:8080/funambol
        ProxyPassReverse http://127.0.0.1:8080/funambol
        PerlHeaderParserHandler My::Package->unprotect
    </Location>

    <Location /Microsoft-Server-ActiveSync>
        Order Allow,Deny
        Allow from All
        ProxyPass http://127.0.0.1:8082/opush/ActiveSyncServlet/
        ProxyPassReverse http://127.0.0.1:8082/opush/ActiveSyncServlet/
        PerlHeaderParserHandler My::Package->unprotect
    </Location>

    <Location /images>
        Order Allow,Deny
        Allow from All
        PerlHeaderParserHandler My::Package->unprotect
    </Location>

    <Location /sso>
        Order Allow,Deny
        Allow from All
    </Location>

    Alias /munin /var/www/munin/
    <Directory /var/www/munin>
        Order Allow,Deny
        Allow from All
        PerlHeaderParserHandler My::Package->unprotect
    </Directory>

# Configuration GLPI

    Alias /glpi   /var/www/glpi
    <Directory /var/www/glpi>
	Options Indexes FollowSymLinks MultiViews
	DirectoryIndex index.php index.html
	AllowOverride None
        Order allow,deny
        allow from all
        PerlHeaderParserHandler My::Package
    </Directory>

#_LEMON_BEGIN_

    # Activation du handler lemonldap-ng
    PerlHeaderParserHandler My::Package

    # Prise en charge des fichiers Perl
    <Files *.pl>
        SetHandler perl-script
        PerlResponseHandler ModPerl::Registry
    </Files>

    # Directory index
    <IfModule mod_dir.c>
        DirectoryIndex index.pl index.html
    </IfModule>

    # Configuration du portail
    Alias /sso/portal /var/lib/lemonldap-ng/portal/
    <Directory /var/lib/lemonldap-ng/portal/>
        Order allow,deny
        Allow from all
        Options +ExecCGI Includes FollowSymlinks
        PerlHeaderParserHandler My::Package->unprotect
    </Directory>
    <Location /sso/portal>
        <IfModule mod_deflate.c>
            AddOutputFilterByType DEFLATE text/html text/plain text/xml text/javascript text/css
            SetOutputFilter DEFLATE
            BrowserMatch ^Mozilla/4 gzip-only-text/html
            BrowserMatch ^Mozilla/4\.0[678] no-gzip
            BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
            SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
        </IfModule>
        <IfModule mod_headers.c>
            Header append Vary User-Agent env=!dont-vary
        </IfModule>
    </Location>
    Alias /sso/portalskins /usr/share/lemonldap-ng/portal-skins/
    <Location /sso/portalskins/>
        <IfModule mod_expires.c>
            ExpiresActive On
            ExpiresDefault "access plus 1 month"
        </IfModule>
        PerlHeaderParserHandler My::Package->unprotect
    </Location>

    # Configuration du manager
    Alias /sso/manager /var/lib/lemonldap-ng/manager/
    <Directory /var/lib/lemonldap-ng/manager>
        Order allow,deny
        Allow from all
        Options +ExecCGI
        PerlHeaderParserHandler My::Package->unprotect
    </Directory>

    # Alias vers la documentation pour Debian Lenny/Squeeze
    Alias /doc /usr/share/doc/lemonldap-ng-doc/
    <Directory /usr/share/doc/lemonldap-ng-doc>
        Order allow,deny
        Allow from all
        Options +ExecCGI
        PerlHeaderParserHandler My::Package->unprotect
    </Directory>

    # Alias vers les librairies
    Alias /lib /usr/share/doc/lemonldap-ng-doc/lib/
    <Directory /usr/share/doc/lemonldap-ng-doc/lib>
        Order allow,deny
        Allow from all
        Options +ExecCGI
        PerlHeaderParserHandler My::Package->unprotect
    </Directory>

    # Alias for javascript
    Alias /javascript /usr/share/javascript/
    <Directory /usr/share/javascript>
        Order allow,deny
        Allow from all
        PerlHeaderParserHandler My::Package->unprotect
    </Directory>

#_LEMON_END_

</VirtualHost>

# Reload vhost for LLNG
# Name resolution in /etc/hosts
<VirtualHost 127.0.0.1:80>
    ServerName reload.mairie.bress

    # Configuration reload mechanism (only 1 per physical server is
    # needed): choose your URL to avoid restarting Apache when
    # configuration change
    <Location /reload>
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/8
        PerlHeaderParserHandler My::Package->refresh
    </Location>

</VirtualHost>
