File tree Expand file tree Collapse file tree 1 file changed +58
-0
lines changed
Expand file tree Collapse file tree 1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change 1+ {
2+ config ,
3+ lib ,
4+ pkgs ,
5+ modulesPath ,
6+ ...
7+ } :
8+ with lib ; let
9+ cfg = config . services . triples ;
10+ in {
11+ options . services . triples = {
12+ enable = mkEnableOption "triples server" ;
13+
14+ nginx = mkOption {
15+ type = types . submodule ( import "${ modulesPath } /services/web-servers/nginx/vhost-options.nix" { inherit config lib ; } ) ;
16+ default = { } ;
17+ description = "Extra configuration for the nginx virtual host of triples." ;
18+ } ;
19+ } ;
20+
21+ config = mkIf cfg . enable {
22+ systemd . services . triples = {
23+ description = "Run triples backend" ;
24+ wantedBy = [ "multi-user.target" ] ;
25+ after = [ "networking.target" ] ;
26+ serviceConfig = {
27+ ExecStart = "${ pkgs . triples-serve } /bin/serve -bot=false -static=${ pkgs . triples-static } /" ;
28+ Restart = "always" ;
29+ } ;
30+ } ;
31+ services . nginx = {
32+ enable = true ;
33+ upstreams . triples-backend . servers . "localhost:8080" = { } ;
34+ virtualHosts . "localhost" = mkMerge [
35+ cfg . nginx
36+ {
37+ # default = true;
38+ # root = mkForce "${cfg.package}/share/fluidd/htdocs";
39+ locations = {
40+ "/api/join" = {
41+ proxyWebsockets = true ;
42+ proxyPass = "http://triples-backend/api/join" ;
43+ extraConfig = ''
44+ # go websocket origin check
45+ # ($http_host instead of $host because the latter strips
46+ # port number, relevant for local vm test)
47+ proxy_set_header Host $http_host;
48+ '' ;
49+ } ;
50+ "/" = {
51+ proxyPass = "http://triples-backend/" ;
52+ } ;
53+ } ;
54+ }
55+ ] ;
56+ } ;
57+ } ;
58+ }
You can’t perform that action at this time.
0 commit comments