<VirtualHost *:{{ apache2_revproxy_config.http_port }}>

        ServerName   {{ apache2_revproxy_config.webserver_name }}
	ServerAdmin  {{ apache2_revproxy_config.serveradmin_email }}
        
	DocumentRoot {{ gsdl3srchome }}/web

        <Directory {{ gsdl3srchome }}/web>
            Require all granted
        </Directory>
	
        #<Directory {{ gsdl3srchome }}/web>
	#    Options +FollowSymLinks
	#    # AllowOverride None
        #</Directory>

	
        # Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
        # error, crit, alert, emerg.
        # It is also possible to configure the loglevel for particular
        # modules, e.g.
        #LogLevel info ssl:warn

        ErrorLog  ${APACHE_LOG_DIR}/{{ apache2_revproxy_config.config_root_name }}-error.log
        CustomLog ${APACHE_LOG_DIR}/{{ apache2_revproxy_config.config_root_name }}-access.log combined


	#Extra-Ansible-Injected#
	
	# To run as a Reverse Proxy, ProxyRequests needs to be off
       	# While this is the default for Apache2, let's be explicitly clear
    	ProxyRequests Off

    	# Needed so baseURL set correctly in LibraryMain.java
    	ProxyPreserveHost On

    	# The following is done to allow the proxied web server (localhost, Tomcat in our case)
    	# to have this header information passed on to it
	#
    	RequestHeader set X-Forwarded-Proto expr=%{REQUEST_SCHEME}
    	#HTTPS# RequestHeader set X-Forwarded-SSL expr=%{HTTPS}

        #
        # Before working with web-sockets, the following config entries were sufficient
	# to connect the apache2 server with the tomcat one running Greenstone3
	#
        # ProxyPass        /{{gsdl3servlet_external.context}} {{gsdl3servlet_internal.protocol}}://{{gsdl3servlet_internal.domain}}:{{gsdl3servlet_internal.port}}/{{gsdl3servlet_internal.context}}
        # ProxyPassReverse /{{gsdl3servlet_external.context}} {{gsdl3servlet_internal.protocol}}://{{gsdl3servlet_internal.domain}}:{{gsdl3servlet_internal.port}}/{{gsdl3servlet_internal.context}}

        # <Location /{{ gsdl3servlet_external.context }}>
        #     ProxyPassReverseCookiePath /{{gsdl3servlet_internal.context}} /{{ gsdl3servlet_external.context }}
        # </Location>

RewriteEngine on
        RewriteRule "^/$" "/greenstone3/library" [END,NE,R=permanent]

#HTTPS#         RewriteCond %{HTTP:Upgrade} =websocket 
#HTTPS#         RewriteRule /(.*) ws://{{gsdl3servlet_internal.domain}}:{{gsdl3servlet_internal.port}}/$1 [P,L]

#HTTPS#         RewriteCond %{HTTP:Upgrade} !=websocket
#HTTPS#         RewriteRule /(.*) http://{{gsdl3servlet_internal.domain}}:{{gsdl3servlet_internal.port}}/$1 [P,L]

</VirtualHost>
