# HG changeset patch # User drewp@bigasterisk.com # Date 2022-05-13 08:07:15 # Node ID bfee787d7b5c7ce38a2e4bd8d06113a38fe336ec # Parent 7ed414bdaab9a87a9fd869fd9b6afd644edf1ead straighten out proxying and nginx+vite mixing diff --git a/bin/collector b/bin/collector --- a/bin/collector +++ b/bin/collector @@ -1,5 +1,5 @@ #!/bin/sh pnpx vite -c light9/collector/web/vite.config.ts & -pdm run uvicorn light9.collector.service:app --host 0.0.0.0 --port 8202 +pdm run uvicorn light9.collector.service:app --host 0.0.0.0 --port 8202 --no-access-log wait 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') diff --git a/light9/ascoltami/vite.config.ts b/light9/ascoltami/vite.config.ts --- a/light9/ascoltami/vite.config.ts +++ b/light9/ascoltami/vite.config.ts @@ -1,18 +1,20 @@ import { defineConfig } from "vite"; +const servicePort = 8206; export default defineConfig({ + base: "/ascoltami/", root: "./light9/ascoltami", publicDir: "../web", server: { host: "0.0.0.0", strictPort: true, - port: 8306, + port: servicePort + 100, hmr: { - port: 8406, + port: servicePort + 200, }, }, + clearScreen: false, define: { global: {}, }, }); - diff --git a/light9/collector/web/index.html b/light9/collector/web/index.html --- a/light9/collector/web/index.html +++ b/light9/collector/web/index.html @@ -63,7 +63,7 @@