
  <%- scope.setvar('_template_scope', {}) -%>
  <%- if @docroot -%>
  ## Directories, there should at least be a declaration for <%= @docroot %>
  <%- else -%>
  ## Directories
  <%- end -%>
  <%- @_directories.each do |directory| -%>
    <%- if directory['path'] and directory['path'] != '' -%>
      <%- if directory['provider'] and directory['provider'].match('(directory|location|files|proxy)') -%>
        <%- if /^(.*)match$/ =~ directory['provider'] -%>
          <%- provider = $1.capitalize + 'Match' -%>
        <%- else -%>
          <%- provider = directory['provider'].capitalize -%>
        <%- end -%>
      <%- else -%>
        <%- provider = 'Directory' -%>
      <%- end -%>
      <%- path = directory['path'] -%>

  <<%= provider %> "<%= path %>">
    <%- if directory['enable_sendfile'] -%>
    EnableSendfile <%= directory['enable_sendfile'] %>
    <%- end -%>
    <%- if directory['headers'] -%>
      <%- Array(directory['headers']).each do |header| -%>
    Header <%= header %>
      <%- end -%>
    <%- end -%>
    <%- if ! directory['geoip_enable'].nil? -%>
    GeoIPEnable <%= scope.call_function('apache::bool2httpd', [directory['geoip_enable']]) %>
    <%- end -%>
    <%- if directory['options'] && Array(directory['options']).any? -%>
    Options <%= Array(directory['options']).join(' ') %>
    <%- end -%>
    <%- if provider == 'Directory' -%>
      <%- if directory['index_options'] -%>
    IndexOptions <%= Array(directory['index_options']).join(' ') %>
      <%- end -%>
      <%- if directory['index_order_default'] -%>
    IndexOrderDefault <%= Array(directory['index_order_default']).join(' ') %>
      <%- end -%>
      <%- if directory['index_style_sheet'] -%>
    IndexStyleSheet '<%= directory['index_style_sheet'] %>'
      <%- end -%>
      <%- if directory['allow_override'] -%>
    AllowOverride <%= Array(directory['allow_override']).join(' ') %>
      <%- elsif provider == 'Directory' -%>
    AllowOverride None
      <%- end -%>
      <%- if directory['allow_override_list'] -%>
    AllowOverrideList <%= Array(directory['allow_override_list']).join(' ') %>
      <%- end -%>
    <%- end -%>
    <%- scope.lookupvar('_template_scope')[:item] = directory -%>
<%= scope.function_template(["apache/vhost/_require.erb"]) -%>
    <%- if directory['limit'] && directory['limit'] != '' -%>
      <%- Array(directory['limit']).each do |lim| -%>
    <Limit <%= lim['methods'] %>>
    <%- scope.lookupvar('_template_scope')[:item] = lim -%>
    <%= scope.function_template(["apache/vhost/_require.erb"]) -%>
    </Limit>
      <%- end -%>
    <%- end -%>
    <%- if directory['limit_except'] && directory['limit_except'] != '' -%>
      <%- Array(directory['limit_except']).each do |lim| -%>
    <LimitExcept <%= lim['methods'] %>>
    <%- scope.lookupvar('_template_scope')[:item] = lim -%>
    <%= scope.function_template(["apache/vhost/_require.erb"]) -%>
    </LimitExcept>
      <%- end -%>
    <%- end -%>
    <%- if directory['addhandlers'] and ! directory['addhandlers'].empty? -%>
      <%- [directory['addhandlers']].flatten.compact.each do |addhandler| -%>
    <FilesMatch ".+(<%= Array(addhandler['extensions']).collect { |s| Regexp.escape(s) }.join('|') %>)$">
        SetHandler <%= addhandler['handler'] %>
    </FilesMatch>
      <%- end -%>
    <%- end -%>
    <%- if directory['sethandler'] and directory['sethandler'] != '' -%>
    SetHandler <%= directory['sethandler'] %>
    <%- end -%>
    <%- unless directory['h2_copy_files'].nil? -%>
    H2CopyFiles <%= scope.call_function('apache::bool2httpd', [directory['h2_copy_files']]) %>
    <%- end -%>
    <%- if directory['h2_push_resource'] && ! directory['h2_push_resource'].empty? -%>
      <%- [directory['h2_push_resource']].flatten.compact.each do |h2_push_resource| -%>
    H2PushResource <%= h2_push_resource %>
      <%- end -%>
    <%- end -%>
    <%- unless directory['passenger_enabled'].nil? -%>
    PassengerEnabled <%= scope.call_function('apache::bool2httpd', [directory['passenger_enabled']]) %>
    <%- end -%>
    <%- if directory['passenger_base_uri'] and ! directory['passenger_base_uri'].empty? -%>
    PassengerBaseURI <%= directory['passenger_base_uri'] %>
    <%- end -%>
    <%- if directory['passenger_ruby'] and ! directory['passenger_ruby'].empty? -%>
    PassengerRuby <%= directory['passenger_ruby'] %>
    <%- end -%>
    <%- if directory['passenger_python'] and ! directory['passenger_python'].empty? -%>
    PassengerPython <%= directory['passenger_python'] %>
    <%- end -%>
    <%- if directory['passenger_nodejs'] and ! directory['passenger_nodejs'].empty? -%>
    PassengerNodejs <%= directory['passenger_nodejs'] %>
    <%- end -%>
    <%- if directory['passenger_meteor_app_settings'] and ! directory['passenger_meteor_app_settings'].empty? -%>
    PassengerMeteorAppSettings <%= directory['passenger_meteor_app_settings'] %>
    <%- end -%>
    <%- if directory['passenger_app_env'] and ! directory['passenger_app_env'].empty? -%>
    PassengerAppEnv <%= directory['passenger_app_env'] %>
    <%- end -%>
    <%- if directory['passenger_app_root'] and ! directory['passenger_app_root'].empty? -%>
    PassengerAppRoot <%= directory['passenger_app_root'] %>
    <%- end -%>
    <%- if directory['passenger_app_group_name'] and ! directory['passenger_app_group_name'].empty? -%>
    PassengerAppGroupName <%= directory['passenger_app_group_name'] %>
    <%- end -%>
    <%- if directory['passenger_app_type'] and ! directory['passenger_app_type'].empty? -%>
    PassengerAppType <%= directory['passenger_app_type'] %>
    <%- end -%>
    <%- if directory['passenger_startup_file'] and ! directory['passenger_startup_file'].empty? -%>
    PassengerStartupFile <%= directory['passenger_startup_file'] %>
    <%- end -%>
    <%- if directory['passenger_restart_dir'] and ! directory['passenger_restart_dir'].empty? -%>
    PassengerRestartDir <%= directory['passenger_restart_dir'] %>
    <%- end -%>
    <%- unless directory['passenger_load_shell_envvars'].nil? -%>
    PassengerLoadShellEnvvars <%= scope.call_function('apache::bool2httpd', [directory['passenger_load_shell_envvars']]) %>
    <%- end -%>
    <%- unless directory['passenger_preload_bundler'].nil? -%>
    PassengerPreloadBundler <%= scope.call_function('apache::bool2httpd', [directory['passenger_preload_bundler']]) %>
    <%- end -%>
    <%- unless directory['passenger_rolling_restarts'].nil? -%>
    PassengerRollingRestarts <%= scope.call_function('apache::bool2httpd', [directory['passenger_rolling_restarts']]) %>
    <%- end -%>
    <%- unless directory['passenger_resist_deployment_errors'].nil? -%>
    PassengerResistDeploymentErrors <%= scope.call_function('apache::bool2httpd', [directory['passenger_resist_deployment_errors']]) %>
    <%- end -%>
    <%- if directory['passenger_user'] and ! directory['passenger_user'].empty? -%>
    PassengerUser <%= directory['passenger_user'] %>
    <%- end -%>
    <%- if directory['passenger_group'] and ! directory['passenger_group'].empty? -%>
    PassengerGroup <%= directory['passenger_group'] %>
    <%- end -%>
    <%- unless directory['passenger_friendly_error_pages'].nil? -%>
    PassengerFriendlyErrorPages <%= scope.call_function('apache::bool2httpd', [directory['passenger_friendly_error_pages']]) %>
    <%- end -%>
    <%- unless directory['passenger_min_instances'].nil? -%>
    PassengerMinInstances <%= directory['passenger_min_instances'] %>
    <%- end -%>
    <%- unless directory['passenger_max_instances'].nil? -%>
    PassengerMaxInstances <%= directory['passenger_max_instances'] %>
    <%- end -%>
    <%- unless directory['passenger_force_max_concurrent_requests_per_process'].nil? -%>
    PassengerForceMaxConcurrentRequestsPerProcess <%= directory['passenger_force_max_concurrent_requests_per_process'] %>
    <%- end -%>
    <%- unless directory['passenger_start_timeout'].nil? -%>
    PassengerStartTimeout <%= directory['passenger_start_timeout'] %>
    <%- end -%>
    <%- if directory['passenger_concurrency_model'] and ! directory['passenger_concurrency_model'].empty? -%>
    PassengerConcurrencyModel <%= directory['passenger_concurrency_model'] %>
    <%- end -%>
    <%- unless directory['passenger_thread_count'].nil? -%>
    PassengerThreadCount <%= directory['passenger_thread_count'] %>
    <%- end -%>
    <%- unless directory['passenger_max_requests'].nil? -%>
    PassengerMaxRequests <%= directory['passenger_max_requests'] %>
    <%- end -%>
    <%- unless directory['passenger_max_request_time'].nil? -%>
    PassengerMaxRequestTime <%= directory['passenger_max_request_time'] %>
    <%- end -%>
    <%- unless directory['passenger_memory_limit'].nil? -%>
    PassengerMemoryLimit <%= directory['passenger_memory_limit'] %>
    <%- end -%>
    <%- unless directory['passenger_high_performance'].nil? -%>
    PassengerHighPerformance <%= scope.call_function('apache::bool2httpd', [directory['passenger_high_performance']]) %>
    <%- end -%>
    <%- unless directory['passenger_buffer_upload'].nil? -%>
    PassengerBufferUpload <%= scope.call_function('apache::bool2httpd', [directory['passenger_buffer_upload']]) %>
    <%- end -%>
    <%- unless directory['passenger_buffer_response'].nil? -%>
    PassengerBufferResponse <%= scope.call_function('apache::bool2httpd', [directory['passenger_buffer_response']]) %>
    <%- end -%>
    <%- unless directory['passenger_error_override'].nil? -%>
    PassengerErrorOverride <%= scope.call_function('apache::bool2httpd', [directory['passenger_error_override']]) %>
    <%- end -%>
    <%- unless directory['passenger_max_request_queue_size'].nil? -%>
    PassengerMaxRequestQueueSize <%= directory['passenger_max_request_queue_size'] %>
    <%- end -%>
    <%- unless directory['passenger_max_request_queue_time'].nil? -%>
    PassengerMaxRequestQueueTime <%= directory['passenger_max_request_queue_time'] %>
    <%- end -%>
    <%- unless directory['passenger_sticky_sessions'].nil? -%>
    PassengerStickySessions <%= scope.call_function('apache::bool2httpd', [directory['passenger_sticky_sessions']]) %>
    <%- end -%>
    <%- if directory['passenger_sticky_sessions_cookie_name'] and ! directory['passenger_sticky_sessions_cookie_name'].empty? -%>
    PassengerStickySessionsCookieName <%= directory['passenger_sticky_sessions_cookie_name'] %>
    <%- end -%>
    <%- unless directory['passenger_allow_encoded_slashes'].nil? -%>
    PassengerAllowEncodedSlashes <%= scope.call_function('apache::bool2httpd', [directory['passenger_allow_encoded_slashes']]) %>
    <%- end -%>
    <%- unless directory['passenger_debugger'].nil? -%>
    PassengerDebugger <%= scope.call_function('apache::bool2httpd', [directory['passenger_debugger']]) %>
    <%- end -%>
    <%- if directory['php_flags'] and ! directory['php_flags'].empty? -%>
      <%- directory['php_flags'].sort.each do |flag,value| -%>
        <%- value = if value =~ /true|yes|on|1/i then 'on' else 'off' end -%>
    php_flag <%= "#{flag} #{value}" %>
      <%- end -%>
    <%- end -%>
    <%- if directory['php_values'] and ! directory['php_values'].empty? -%>
      <%- directory['php_values'].sort.each do |key,value| -%>
    php_value <%= "#{key} #{value}" %>
      <%- end -%>
    <%- end -%>
    <%- if directory['php_admin_flags'] and ! directory['php_admin_flags'].empty? -%>
      <%- directory['php_admin_flags'].sort.each do |flag,value| -%>
        <%- value = if value =~ /true|yes|on|1/i then 'on' else 'off' end -%>
    php_admin_flag <%= "#{flag} #{value}" %>
      <%- end -%>
    <%- end -%>
    <%- if directory['php_admin_values'] and ! directory['php_admin_values'].empty? -%>
      <%- directory['php_admin_values'].sort.each do |key,value| -%>
    php_admin_value <%= "#{key} #{value}" %>
      <%- end -%>
    <%- end -%>
    <%- if directory['directoryindex'] and directory['directoryindex'] != '' -%>
    DirectoryIndex <%= directory['directoryindex'] %>
    <%- end -%>
    <%- if directory['additional_includes'] and ! directory['additional_includes'].empty? -%>
      <%- directory['additional_includes'].each do |include| -%>
    Include '<%= "#{include}" %>'
      <%- end -%>
    <%- end -%>
    <%- if directory['error_documents'] and ! directory['error_documents'].empty? -%>
      <%- [directory['error_documents']].flatten.compact.each do |error_document| -%>
    ErrorDocument <%= error_document['error_code'] %> <%= error_document['document'] %>
      <%- end -%>
    <%- end -%>
    <%- if directory['dav'] -%>
    Dav <%= directory['dav'] %>
    <%- if directory['dav_depth_infinity'] -%>
    DavDepthInfinity <%= scope.call_function('apache::bool2httpd', [directory['dav_depth_infinity']]) %>
    <%- end -%>
    <%- if directory['dav_min_timeout'] -%>
    DavMinTimeout <%= directory['dav_min_timeout'] %>
    <%- end -%>
    <%- end -%>
    <%- if directory['auth_type'] -%>
    AuthType <%= directory['auth_type'] %>
    <%- end -%>
    <%- if directory['auth_name'] -%>
    AuthName "<%= directory['auth_name'] %>"
    <%- end -%>
    <%- if directory['auth_digest_algorithm'] -%>
    AuthDigestAlgorithm <%= directory['auth_digest_algorithm'] %>
    <%- end -%>
    <%- if directory['auth_digest_domain'] -%>
    AuthDigestDomain <%= Array(directory['auth_digest_domain']).join(' ') %>
    <%- end -%>
    <%- if directory['auth_digest_nonce_lifetime'] -%>
    AuthDigestNonceLifetime <%= directory['auth_digest_nonce_lifetime'] %>
    <%- end -%>
    <%- if directory['auth_digest_provider'] -%>
    AuthDigestProvider <%= directory['auth_digest_provider'] %>
    <%- end -%>
    <%- if directory['auth_digest_qop'] -%>
    AuthDigestQop <%= directory['auth_digest_qop'] %>
    <%- end -%>
    <%- if directory['auth_digest_shmem_size'] -%>
    AuthDigestShmemSize <%= directory['auth_digest_shmem_size'] %>
    <%- end -%>
    <%- if directory['auth_basic_authoritative'] -%>
    AuthBasicAuthoritative <%= directory['auth_basic_authoritative'] %>
    <%- end -%>
    <%- if directory['auth_basic_fake'] -%>
    AuthBasicFake <%= directory['auth_basic_fake'] %>
    <%- end -%>
    <%- if directory['auth_basic_provider'] -%>
    AuthBasicProvider <%= directory['auth_basic_provider'] %>
    <%- end -%>
    <%- if directory['auth_user_file'] -%>
    AuthUserFile <%= directory['auth_user_file'] %>
    <%- end -%>
    <%- if directory['auth_group_file'] -%>
    AuthGroupFile <%= directory['auth_group_file'] %>
    <%- end -%>
    <%- if directory['auth_merging'] -%>
    AuthMerging <%= directory['auth_merging'] %>
    <%- end -%>
    <%- if directory['auth_ldap_referrals'] -%>
    LDAPReferrals <%= directory['auth_ldap_referrals'] %>
    <%- end -%>
    <%- if directory['auth_ldap_url'] -%>
    AuthLDAPURL <%= directory['auth_ldap_url'] %>
    <%- end -%>
    <%- if directory['auth_ldap_bind_dn'] -%>
    AuthLDAPBindDN <%= directory['auth_ldap_bind_dn'] %>
    <%- end -%>
    <%- if directory['auth_ldap_bind_password'] -%>
    AuthLDAPBindPassword <%= directory['auth_ldap_bind_password'] %>
    <%- end -%>
    <%- if directory['auth_ldap_group_attribute'] -%>
      <%- Array(directory['auth_ldap_group_attribute']).each do |groupattr| -%>
    AuthLDAPGroupAttribute <%= groupattr %>
      <%- end -%>
    <%- end -%>
    <%- unless directory['auth_ldap_group_attribute_is_dn'].nil? -%>
    AuthLDAPGroupAttributeIsDN <%= scope.call_function('apache::bool2httpd', [ directory['auth_ldap_group_attribute_is_dn'] ]) %>
    <%- end -%>
    <%- if directory['auth_ldap_initial_bind_pattern'] -%>
    AuthLDAPInitialBindPattern <%= directory['auth_ldap_initial_bind_pattern'] %>
    <%- end -%>
    <%- unless directory['auth_ldap_bind_as_user'].nil? -%>
    AuthLDAPInitialBindAsUser <%= scope.call_function('apache::bool2httpd', [ directory['auth_ldap_bind_as_user'] ]) %>
    <%- end -%>
    <%- unless directory['auth_ldap_compare_as_user'].nil? -%>
    AuthLDAPCompareAsUser <%= scope.call_function('apache::bool2httpd', [ directory['auth_ldap_compare_as_user'] ]) %>
    <%- end -%>
    <%- unless directory['auth_ldap_search_as_user'].nil? -%>
    AuthLDAPSearchAsUser <%= scope.call_function('apache::bool2httpd', [ directory['auth_ldap_search_as_user'] ]) %>
    <%- end -%>
    <%- unless directory['auth_ldap_bind_authoritative'].nil? -%>
    AuthLDAPBindAuthoritative <%= scope.call_function('apache::bool2httpd', [ directory['auth_ldap_bind_authoritative'] ]) %>
    <%- end -%>
    <%- if directory['auth_ldap_authorize_prefix'] -%>
    AuthLDAPAuthorizePrefix <%= directory['auth_ldap_authorize_prefix'] %>
    <%- end -%>
    <%- if directory['auth_ldap_charset_config'] -%>
    AuthLDAPCharsetConfig <%= directory['auth_ldap_charset_config'] %>
    <%- end -%>
    <%- unless directory['auth_ldap_compare_dn_on_server'].nil? -%>
    AuthLDAPCompareDNOnServer <%= scope.call_function('apache::bool2httpd', [ directory['auth_ldap_compare_dn_on_server'] ]) %>
    <%- end -%>
    <%- if directory['auth_ldap_dereference_aliases'] -%>
    AuthLDAPDereferenceAliases <%= directory['auth_ldap_dereference_aliases'] %>
    <%- end -%>
    <%- if directory['auth_ldap_max_sub_group_depth'] -%>
    AuthLDAPMaxSubGroupDepth <%= directory['auth_ldap_max_sub_group_depth'] %>
    <%- end -%>
    <%- if directory['auth_ldap_remote_user_attribute'] -%>
    AuthLDAPRemoteUserAttribute <%= directory['auth_ldap_remote_user_attribute'] %>
    <%- end -%>
    <%- unless directory['auth_ldap_remote_user_is_dn'].nil? -%>
    AuthLDAPRemoteUserIsDN <%= scope.call_function('apache::bool2httpd', [ directory['auth_ldap_remote_user_is_dn'] ]) %>
    <%- end -%>
    <%- if directory['auth_ldap_sub_group_attribute'] -%>
    AuthLDAPSubGroupAttribute <%= directory['auth_ldap_sub_group_attribute'] %>
    <%- end -%>
    <%- if directory['auth_ldap_sub_group_class'] -%>
    AuthLDAPSubGroupClass <%= directory['auth_ldap_sub_group_class'] %>
    <%- end -%>
    <%- if directory['fallbackresource'] -%>
    FallbackResource <%= directory['fallbackresource'] %>
    <%- end -%>
    <%- if directory['expires_active'] -%>
    ExpiresActive <%= directory['expires_active'] %>
    <%- end -%>
    <%- if directory['expires_default'] -%>
    ExpiresDefault "<%= directory['expires_default'] %>"
    <%- end -%>
    <%- if directory['expires_by_type'] -%>
    <%- Array(directory['expires_by_type']).each do |rule| -%>
    ExpiresByType <%= rule %>
    <%- end -%>
    <%- end -%>
    <%- if directory['ext_filter_options'] -%>
    ExtFilterOptions <%= directory['ext_filter_options'] %>
    <%- end -%>
    <%- if directory['force_type'] -%>
    ForceType <%= directory['force_type'] %>
    <%- end -%>
    <%- if directory['add_charset'] -%>
    AddCharset <%= directory['add_charset'] %>
    <%- end -%>
    <%- if directory['ssl_options'] -%>
    SSLOptions <%= Array(directory['ssl_options']).join(' ') %>
    <%- end -%>
    <%- if directory['ssl_verify_client'] and directory['ssl_verify_client'].match('(none|optional|require|optional_no_ca)') -%>
    SSLVerifyClient <%= directory['ssl_verify_client'] %>
    <%- if directory['ssl_verify_depth'] -%>
    SSLVerifyDepth <%= directory['ssl_verify_depth'] %>
    <%- end -%>
    <%- end -%>
    <%- if directory['fcgiwrapper'] -%>
    FcgidWrapper <%= directory['fcgiwrapper']['command'] %> <%= directory['fcgiwrapper']['suffix'] %> <%= directory['fcgiwrapper']['virtual'] %>
    <%- end -%>
    <%- if directory['rewrites'] -%>
    # Rewrite rules
    RewriteEngine On
      <%- directory['rewrites'].flatten.compact.each do |rewrite_details| -%>
        <%- if rewrite_details['comment'] -%>
    #<%= rewrite_details['comment'] %>
        <%- end -%>
        <%- if rewrite_details['rewrite_base'] -%>
    RewriteBase <%= rewrite_details['rewrite_base'] %>
        <%- end -%>
        <%- if rewrite_details['rewrite_cond'] -%>
          <%- Array(rewrite_details['rewrite_cond']).each do |commands| -%>
            <%- Array(commands).each do |command| -%>
    RewriteCond <%= command %>
            <%- end -%>
          <%- end -%>
        <%- end -%>
        <%- Array(rewrite_details['rewrite_rule']).each do |commands| -%>
          <%- Array(commands).each do |command| -%>
    RewriteRule <%= command %>
          <%- end -%>
        <%- end -%>
      <%- end -%>
    <%- end -%>
    <%- if directory['setenv'] -%>
      <%- Array(directory['setenv']).each do |setenv| -%>
    SetEnv <%= setenv %>
      <%- end -%>
    <%- end -%>
    <%- if directory['set_output_filter'] -%>
    SetOutputFilter <%= directory['set_output_filter'] %>
    <%- end -%>
    <%- if directory['set_input_filter'] -%>
    SetInputFilter <%= directory['set_input_filter'] %>
    <%- end -%>
    <%- if @shibboleth_enabled -%>
      <%- if directory['shib_require_session'] and ! directory['shib_require_session'].empty? -%>
    ShibRequireSession <%= directory['shib_require_session'] %>
      <%- end -%>
      <%- if directory['shib_request_settings'] and ! directory['shib_request_settings'].empty? -%>
        <%- directory['shib_request_settings'].each do |key,value| -%>
    ShibRequestSetting <%= key %> <%= value %>
        <%- end -%>
      <%- end -%>
      <%- if directory['shib_use_headers'] and ! directory['shib_use_headers'].empty? -%>
    ShibUseHeaders <%= directory['shib_use_headers'] %>
      <%- end -%>
    <%- end -%>
    <%- if @cas_enabled -%>
      <%- if directory['cas_scope'] -%>
    CASScope <%= directory['cas_scope'] %>
      <%- end -%>
      <%- if directory['cas_renew'] -%>
    CASRenew <%= directory['cas_renew'] %>
      <%- end -%>
      <%- if directory['cas_gateway'] -%>
    CASGateway <%= directory['cas_gateway'] %>
      <%- end -%>
      <%- if directory['cas_cookie'] -%>
    CASCookie <%= directory['cas_cookie'] %>
      <%- end -%>
      <%- if directory['cas_secure_cookie'] -%>
    CASSecureCookie <%= directory['cas_secure_cookie'] %>
      <%- end -%>
      <%- if directory['cas_gateway_cookie'] -%>
    CASGatewayCookie <%= directory['cas_gateway_cookie'] %>
      <%- end -%>
      <%- if directory['cas_authn_header'] -%>
    CASAuthNHeader <%= directory['cas_authn_header'] %>
      <%- end -%>
    <%- end -%>
    <%- if directory['mellon_enable'] -%>
    MellonEnable "<%= directory['mellon_enable'] %>"
      <%- if directory['mellon_endpoint_path'] -%>
    MellonEndpointPath "<%= directory['mellon_endpoint_path'] %>"
      <%- end -%>
      <%- if directory['mellon_sp_private_key_file'] -%>
    MellonSPPrivateKeyFile "<%= directory['mellon_sp_private_key_file'] %>"
      <%- end -%>
      <%- if directory['mellon_sp_cert_file'] -%>
    MellonSPCertFile "<%= directory['mellon_sp_cert_file'] %>"
      <%- end -%>
      <%- if directory['mellon_sp_metadata_file'] -%>
    MellonSPMetadataFile "<%= directory['mellon_sp_metadata_file'] %>"
      <%- end -%>
      <%- if directory['mellon_idp_metadata_file'] -%>
    MellonIDPMetadataFile "<%= directory['mellon_idp_metadata_file'] %>"
      <%- end -%>
      <%- if directory['mellon_set_env'] -%>
        <%- directory['mellon_set_env'].each do |key, value| -%>
    MellonSetEnv "<%= key %>" "<%= value %>"
        <%- end -%>
      <%- end -%>
      <%- if directory['mellon_set_env_no_prefix'] -%>
        <%- directory['mellon_set_env_no_prefix'].each do |key, value| -%>
    MellonSetEnvNoPrefix "<%= key %>" "<%= value %>"
        <%- end -%>
      <%- end -%>
      <%- if directory['mellon_user'] -%>
    MellonUser "<%= directory['mellon_user'] %>"
      <%- end -%>
      <%- if directory['mellon_saml_response_dump'] -%>
    MellonSamlResponseDump "<%= directory['mellon_saml_response_dump'] %>"
      <%- end -%>
      <%- if directory['mellon_cond'] -%>
        <%- Array(directory['mellon_cond']).each do |cond| -%>
    MellonCond <%= cond %>
         <%- end -%>
      <%- end -%>
      <%- if directory['mellon_session_length'] -%>
    MellonSessionLength "<%= directory['mellon_session_length'] %>"
      <%- end -%>
    <%- end -%>
    <%- if directory['request_headers'] and ! directory['request_headers'].empty? -%>
      ## Request Header rules
      <%- Array(directory['request_headers']).each do |request_statement| -%>
        <%- if request_statement != '' -%>
            RequestHeader <%= request_statement %>
        <%- end -%>
      <%- end -%>
    <%- end -%>
    <%- if (directory['proxy_pass'] or directory['proxy_pass_match']) and directory['provider'] and directory['provider'].match('location') -%>
      <%# In a Location container, only one of ProxyPass or ProxyPassMatch are allowed, so only need to handle on case at a time -%>
         <%- if directory['proxy_pass_match']
               proxy_pass = 'ProxyPassMatch'
               directory_proxy_pass = directory['proxy_pass_match']
             else
               proxy_pass = 'ProxyPass'
               directory_proxy_pass = directory['proxy_pass']
             end -%>
      <%- directory_proxy_pass.flatten.compact.each do |proxy| -%>
    <%= proxy_pass -%> <%= proxy['url'] -%>
        <%- if proxy['params'] -%>
          <%- proxy['params'].sort.each do |key, value| -%> <%= key %>=<%= value -%>
          <%- end -%>
        <%- end -%>
        <%- if proxy['keywords'] %> <%= proxy['keywords'].join(' ') -%>
        <%- end %>
        <%- if not proxy['reverse_cookies'].nil? -%>
          <%- Array(proxy['reverse_cookies']).each do |reverse_cookies| -%>
            <%- if reverse_cookies['path'] -%>
    ProxyPassReverseCookiePath <%= reverse_cookies['path'] %> <%= reverse_cookies['url'] %>
            <%- end -%>
            <%- if reverse_cookies['domain'] -%>
    ProxyPassReverseCookieDomain <%= reverse_cookies['domain'] %> <%= reverse_cookies['url'] %>
            <%- end -%>
          <%- end -%>
        <%- end -%>
        <%- if proxy['reverse_urls'].nil? -%>
    ProxyPassReverse <%= proxy['url'] %>
        <%- else -%>
          <%- Array(proxy['reverse_urls']).each do |reverse_url| -%>
    ProxyPassReverse <%= reverse_url %>
          <%- end -%>
        <%- end -%>
        <%- if proxy['setenv'] -%>
          <%- Array(proxy['setenv']).each do |setenv_var| -%>
    SetEnv <%= setenv_var %>
          <%- end -%>
        <%- end -%>
      <% end -%>
    <%- end -%>
    <%- if directory['custom_fragment'] -%>
    <%= directory['custom_fragment'] %>
    <%- end -%>
    <%- if directory['authz_core'] -%>
      <%= scope.call_function('epp',["apache/vhost/_authz_core.epp", 'authz_core_config' => scope.call_function('apache::authz_core_config', [ directory['authz_core'] ]) ]) -%>
    <%- end -%>
    <%- if directory['gssapi'] -%>
      <%= scope.call_function('epp',["apache/vhost/_gssapi.epp", directory['gssapi']]) -%>
    <%- end -%>
  </<%= provider %>>
    <%- end -%>
  <%- end -%>
