From b5ff94dd276b454a400ca0a4616169984189b183 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 3 Aug 2016 13:07:53 +0200 Subject: nginx reverse proxy on bragi --- bragi.nix | 56 +++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 55 insertions(+), 1 deletion(-) diff --git a/bragi.nix b/bragi.nix index c457ae3e..1477410c 100644 --- a/bragi.nix +++ b/bragi.nix @@ -325,12 +325,66 @@ in rec { wantedBy = [ "default.target" ]; serviceConfig = { Type = "simple"; - ExecStart = ''${pkgs.thermoprint-webgui}/bin/thermoprint-webgui -P 8080 -A localhost -a "*" -p 8081''; + ExecStart = ''${pkgs.thermoprint-webgui}/bin/thermoprint-webgui -P 80 -A localhost -F thermoprint/api -a "*" -p 8081''; User = users.extraUsers."thermoprint".name; Group = users.extraUsers."thermoprint".group; }; }; + services.nginx = { + enable = true; + httpConfig = '' + default_type application/octet-stream; + + log_format main + '$remote_addr - $remote_user [$time_local] ' + '"$request" $status $bytes_sent ' + '"$http_referer" "$http_user_agent" ' + '"$gzip_ratio"'; + + client_header_timeout 10m; + client_body_timeout 10m; + send_timeout 10m; + + connection_pool_size 256; + client_header_buffer_size 1k; + large_client_header_buffers 4 2k; + request_pool_size 4k; + + gzip on; + gzip_min_length 1100; + gzip_buffers 4 8k; + gzip_types text/plain; + + output_buffers 1 32k; + postpone_output 1460; + + sendfile on; + tcp_nopush on; + tcp_nodelay on; + + keepalive_timeout 75 20; + + ignore_invalid_headers on; + + access_log stderr; + error_log stderr; + + server { + listen *:80; + server_name _; + + location /thermoprint/api { + proxy_pass http://localhost:8081; + } + + location /thermoprint { + proxy_pass http://localhost:8080; + } + } + ''; + }; + nix = { daemonIONiceLevel = 3; daemonNiceLevel = 10; -- cgit v1.2.3