diff --git a/bin/homepageConfig b/bin/homepageConfig --- a/bin/homepageConfig +++ b/bin/homepageConfig @@ -15,20 +15,33 @@ if not webServer: print("listen %s;" % splitport(urlparse(webServer).netloc)[1]) -def location(path, server): +def location(path, server, viteServer): print(f""" - location /{path}/ {{ + + location = /{path}/metrics {{ + rewrite ^/{path}(/.*) $1 break; + proxy_pass {server}; + }} - # for websocket - proxy_http_version 1.1; - proxy_set_header Upgrade $http_upgrade; - proxy_set_header Connection "upgrade"; - proxy_set_header Host $host; + location /{path}/api/ {{ + # just the tail part for services + rewrite ^/{path}/api(/.*) $1 break; + proxy_pass {server}; + }} + location /{path}/ {{ + # vite has 'base' to deal with the /{path}/ part of the request + proxy_pass {viteServer}; + }} - proxy_pass {server}; - proxy_buffering off; - rewrite /[^/]+/(.*) /$1 break; - }}""") +# vite seems to work without this old section-- hopefully other services will too! + # # for websocket + # proxy_http_version 1.1; + # proxy_set_header Upgrade $http_upgrade; + # proxy_set_header Connection "upgrade"; + # proxy_set_header Host $host; + + # proxy_buffering off; + """) for role, server in sorted(graph.predicate_objects(netHome)): @@ -38,20 +51,8 @@ for role, server in sorted(graph.predica 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; - } - -''') + viteServer = server.replace('820', '830') # rewrite this please + location(path, server, viteServer) showPath = showconfig.showUri().split('/', 3)[-1] root = showconfig.root()[:-len(showPath)].decode('ascii')