Changeset - e9dc435cc946
[Not reviewed]
default
0 2 0
drewp@bigasterisk.com - 20 months ago 2023-05-27 22:44:16
drewp@bigasterisk.com
no proxy_buffering even on vitejs resource pages, since our working dir is non-writable
2 files changed with 2 insertions and 3 deletions:
0 comments (0 inline, 0 general)
bin/homepage
Show inline comments
 
#!/bin/zsh
 

	
 
CONF=/tmp/light9_nginx.conf
 
ROOT=`dirname $0`/..
 
ROOT=${ROOT:a}
 

	
 
bin/python light9/homepage/write_config.py /tmp/light9_nginx_routes.conf && \
 
cat > $CONF <<EOF
 
worker_processes 1;
 

	
 
daemon off;
 
error_log /tmp/light9_homepage.err;
 
pid /dev/null;
 

	
 
events {
 
  worker_connections 1024;
 
}
 

	
 
http {
 
 include $ROOT/light9/web/mime.types;
 
 
 
 proxy_buffering off;
 

	
 
 server {
 
  access_log off;
 
  autoindex on;
 

	
 
  include "/tmp/light9_nginx_routes.conf";
 

	
 
  location / {
 
    proxy_pass http://localhost:8300;
 
  }
 

	
 
 }
 
}
 
EOF
 
pnpm vite -c light9/homepage/vite.config.ts &
 
/usr/sbin/nginx -c $CONF
 
wait
light9/homepage/write_config.py
Show inline comments
 
@@ -18,51 +18,48 @@ def main():
 

	
 
    with open(outPath, 'wt') as out:
 
        line = "listen %s;" % urlparse(str(webServer)).port
 
        print(line, file=out)
 
        log.info(line)
 

	
 
        def location(path, server, viteServer):
 
            print(f"""
 

	
 
        location = /{path}/metrics {{
 
          rewrite ^/{path}(/.*) $1 break;
 
          proxy_pass {server}; 
 
        }}
 

	
 
        location /{path}/api/ {{
 
          # just the tail part for services
 
          rewrite ^/{path}/api(/.*) $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;
 

	
 
          proxy_buffering off;
 

	
 
        }}
 
        location /{path}/ {{
 
          # vite has 'base' to deal with the /{path}/ part of the request
 
          proxy_pass {viteServer}; 
 
        }}
 

	
 
        """,
 
                  file=out)
 

	
 
        for role, server in sorted(graph.predicate_objects(netHome)):
 
            if not str(server).startswith('http') or role == L9['webServer']:
 
                continue
 
            path = graph.value(role, L9['urlPath'])
 
            if not path:
 
                continue
 
            server = str(server).rstrip('/')
 
            viteServer = server.replace('82', '83')  # rewrite this please
 
            location(path, server, viteServer)
 

	
 
        showPath = showconfig.showUri().split('/', 3)[-1]
 
        root = showconfig.root()[:-len(showPath)].decode('ascii')
 
        print(f"""
 
        location /{showPath} {{
 
          root {root};
0 comments (0 inline, 0 general)