Files
@ f8a5f579547a
Branch filter:
Location: light9/bin/homepageConfig - annotation
f8a5f579547a
1.5 KiB
text/plain
make deps
0d295af23c4b 0d295af23c4b 3c523c71da29 0d295af23c4b f066d6e874db f066d6e874db 0d295af23c4b 3c523c71da29 70f42f9d6e04 0d295af23c4b 70f42f9d6e04 15f296550447 15f296550447 15f296550447 f066d6e874db e703b3434dbd 7772cc48e016 cec677a84142 ec6ec713c276 ec6ec713c276 e703b3434dbd 70f42f9d6e04 70f42f9d6e04 70f42f9d6e04 70f42f9d6e04 70f42f9d6e04 0d295af23c4b ec6ec713c276 c8cffe82b537 70f42f9d6e04 ec6ec713c276 cec677a84142 7772cc48e016 cec677a84142 cec677a84142 cec677a84142 cec677a84142 cec677a84142 cec677a84142 cec677a84142 04ed5d134973 cec677a84142 cec677a84142 04ed5d134973 04ed5d134973 04ed5d134973 04ed5d134973 04ed5d134973 04ed5d134973 04ed5d134973 04ed5d134973 04ed5d134973 04ed5d134973 04ed5d134973 04ed5d134973 cec677a84142 ec6ec713c276 ec6ec713c276 ec6ec713c276 ec6ec713c276 ec6ec713c276 | #!bin/python
from run_local import log
from light9 import showconfig
from light9.namespaces import L9
from urllib.parse import urlparse
from urllib.parse import splitport
log.info('generating config')
graph = showconfig.getGraph()
netHome = graph.value(showconfig.showUri(), L9['networking'])
webServer = graph.value(netHome, L9['webServer'])
if not webServer:
raise ValueError('no %r :webServer' % netHome)
print("listen %s;" % splitport(urlparse(webServer).netloc)[1])
def location(path, server):
print(f"""
location /{path}/ {{
# for websocket
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_pass {server};
proxy_buffering off;
rewrite /[^/]+/(.*) /$1 break;
}}""")
for role, server in sorted(graph.predicate_objects(netHome)):
if not server.startswith('http') or role == L9['webServer']:
continue
path = graph.value(role, L9['urlPath'])
if not path:
continue
server = server.rstrip('/')
if 'collector' in path: continue
location(path, server)
print('''
location /collector/metrics {
rewrite "/collector(/.*)" "$1" break;
proxy_pass http://localhost:8202;
}
location /collector/ {
proxy_pass http://localhost:8302;
}
''')
showPath = showconfig.showUri().split('/', 3)[-1]
root = showconfig.root()[:-len(showPath)].decode('ascii')
print(f"""
location /{showPath} {{
root {root};
}}""")
|