def _apache_generation(directory, base_url, ports, static_directories):
    apache_conf = (
    "\n"
    """<LocationMatch (.*)nocache\.js$>\n"""
    """   Header Set Cache-Control "max-age=0, no-store"\n"""
    """</LocationMatch>\n"""
    """\n"""
    """<Files *.cache.*>\n"""
    """   Header Set Cache-Control "max-age=2592000"\n"""
    """</Files>\n"""
    """\n"""
    """# Apache redirects the regular paths to the particular directories \n"""
#    """RedirectMatch ^%(root)s$ %(root)s/weblab/\n"""
#    """RedirectMatch ^%(root)s/$ %(root)s/weblab/\n"""
    """RedirectMatch ^%(root)s/weblab$ %(root)s/weblab/\n"""
    """RedirectMatch ^%(root)s/weblab/client/$ %(root)s/weblab/client/index.html\n"""
    """\n""")
    
    for static_url, static_directory in static_directories.items():
        apache_conf += """Alias %(static_url)s   %(static_directory)s\n""" % dict(static_url=static_url, static_directory=static_directory)

    apache_conf += (
    """\n"""
    """<Location %(root)s/weblab/>\n"""
    """    <IfModule authz_core_module>\n"""
    """        Require all granted\n"""
    """    </IfModule>\n"""
    """\n"""
    """    <IfModule !authz_core_module>\n"""
    """        Order allow,deny\n"""
    """        Allow from All\n"""
    """    </IfModule>\n"""
    """</Location>\n"""
    """\n"""
    """<Directory "%(directory)s">\n"""
    """    Options Indexes\n"""
    """\n"""
    """    <IfModule authz_core_module>\n"""
    """        Require all granted\n"""
    """    </IfModule>\n"""
    """\n"""
    """    <IfModule !authz_core_module>\n"""
    """        Order allow,deny\n"""
    """        Allow from All\n"""
    """    </IfModule>\n"""
    """</Directory>\n"""
    """\n""")

    previous = []
    for static_directory in static_directories.values():
        if static_directory in previous:
            continue
        previous.append(static_directory)
        apache_conf += ("""<Directory "%(static_directory)s">\n"""
        """    Options Indexes FollowSymLinks\n"""
        """\n"""
        """    <IfModule authz_core_module>\n"""
        """        Require all granted\n"""
        """    </IfModule>\n"""
        """\n"""
        """    <IfModule !authz_core_module>\n"""
        """        Order allow,deny\n"""
        """        Allow from All\n"""
        """    </IfModule>\n"""
        """</Directory>\n"""
        """\n""") % dict(static_directory=static_directory)

    apache_conf += (
    """# Apache redirects the requests retrieved to the particular server, using a stickysession if the sessions are based on memory\n"""
    """ProxyPreserveHost On\n"""
    """ProxyVia On\n"""
    """\n""")

    for static_url, static_directory in static_directories.items():
        apache_conf += """ProxyPass %(static_url)s !\n""" % dict(static_url=static_url)

    apache_conf += (
    """\n"""
    """ProxyPass                       %(root)s/weblab/                 balancer://%(root-no-slash)s_weblab_cluster/           stickysession=weblabsessionid lbmethod=bybusyness\n"""
    """ProxyPassReverse                %(root)s/weblab/                 balancer://%(root-no-slash)s_weblab_cluster/           stickysession=weblabsessionid\n"""
    "\n")
    apache_conf += "\n"
    apache_conf += """<Proxy balancer://%(root-no-slash)s_weblab_cluster>\n"""

    for pos, port in enumerate(ports):
        d = { 'port' : port, 'route' : 'route%s' % (pos+1), 'root' : '%(root)s' }
        apache_conf += """    BalancerMember http://localhost:%(port)s/weblab route=%(route)s\n""" % d

    apache_conf += """</Proxy>\n"""
    apache_img_dir = '/client/images'

    apache_root_without_slash = base_url[1:] if base_url.startswith('/') else base_url

    server_conf_dict = { 'root' : base_url,  'root-no-slash' : apache_root_without_slash.replace('/','_'),
                'directory' : os.path.abspath(directory).replace('\\','/'),
                'war_path' : data_filename('war').replace('\\','/') }

    apache_conf = apache_conf % server_conf_dict
    apache_conf_path = os.path.join('', 'apache_weblab_generic.conf')
    return apache_conf
dataset/ETHPy150Open weblabdeusto/weblabdeusto/server/src/weblab/admin/script/httpd_config_generate.py/_apache_generation/original