MCPcopy Create free account
hub / github.com/omkarcloud/botasaurus / make_apache_content

Function make_apache_content

bota/src/bota/apache_utils.py:35–49  ·  view source on GitHub ↗
(apache_conf, root_path, api_target)

Source from the content-addressed store, hash-verified

33 return re.sub(r'</VirtualHost>', f' ProxyPass {root_path} {api_target}\n ProxyPassReverse {root_path} {api_target}\n</VirtualHost>', apache_conf)
34
35def make_apache_content(apache_conf, root_path, api_target):
36 replace_conf = """\n\t# The ServerName directive sets the request scheme, hostname and port that\n\t# the server uses to identify itself. This is used when creating\n\t# redirection URLs. In the context of virtual hosts, the ServerName\n\t# specifies what hostname must appear in the request's Host: header to\n\t# match this virtual host. For the default virtual host (this file) this\n\t# value is not decisive as it is used as a last resort host regardless.\n\t# However, you must set it for any further virtual host explicitly.\n\t#ServerName www.example.com\n\n\tServerAdmin webmaster@localhost"""
37 # Remove replace_conf content
38 apache_conf = apache_conf.replace(replace_conf, "").replace(replace_conf.strip(), "")
39
40
41 # Remove existing ProxyPass and ProxyPassReverse directives for the root_path
42 apache_conf = clean_conf(apache_conf, root_path)
43
44 # Add new ProxyPass and ProxyPassReverse directives based on the root_path
45 if root_path == "/":
46 return collapse_empty_lines(sub_at_end(apache_conf, root_path, api_target))
47 else:
48 # Add new directives right after the VirtualHost opening tag
49 return collapse_empty_lines(sub_at_start(apache_conf, root_path, api_target))
50
51def remove_apache_proxy_config(root_path):
52 """

Calls 4

clean_confFunction · 0.85
collapse_empty_linesFunction · 0.85
sub_at_endFunction · 0.85
sub_at_startFunction · 0.85

Tested by

no test coverage detected