Skip to content

Commit

Permalink
Move nginx.conf out of flake
Browse files Browse the repository at this point in the history
  • Loading branch information
jhh committed Feb 3, 2024
1 parent 270975c commit 66977e3
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 131 deletions.
81 changes: 12 additions & 69 deletions web/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -38,71 +38,16 @@
let
nginxPort = "80";
nginxWebRoot = self.packages.${system}.deadeye-web;
nginxConf = pkgs.writeText "nginx.conf" ''
user nobody nobody;
daemon off;
error_log /dev/stdout info;
pid /dev/null;
events {}
http {
include ${pkgs.nginx}/conf/mime.types;
access_log /dev/stdout;
server {
listen ${nginxPort};
location / {
root ${nginxWebRoot};
index index.html;
try_files $uri $uri/ /index.html;
}
location /socket.io/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_http_version 1.1;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://admin:5000;
}
location /upload {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://admin:5000;
}
location /stream/0/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://daemon:5805/stream.mjpg;
}
location /stream/1/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://daemon:5806/stream.mjpg;
}
location /stream/2/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://daemon:5807/stream.mjpg;
}
location /stream/3/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://daemon:5808/stream.mjpg;
}
location /stream/4/ {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_pass http://daemon:5809/stream.mjpg;
}
}
}
'';
nginxConf = pkgs.writeText "nginx.conf" (builtins.replaceStrings [
"%NGINX_PORT%"
"%WEB_ROOT%"
"%MIME_TYPES%"
] [
"${nginxPort}"
"${nginxWebRoot}"
"${pkgs.nginx}/conf/mime.types"
]
(builtins.readFile ./nginx.conf));
in
pkgs.dockerTools.buildLayeredImage {
name = "j3ff/deadeye-web";
Expand All @@ -120,17 +65,15 @@

config = {
Cmd = [ "nginx" "-c" nginxConf ];
ExposedPorts = {
"${nginxPort}/tcp" = { };
};
ExposedPorts = { "${nginxPort}/tcp" = { }; };
};
};

packages.default = self.packages.${system}.deadeye-web;

#
devShells.default = pkgs.mkShell {
# inputsFrom = [ self.packages.${system}.deadeye-admin ];
# inputsFrom = [ self.packages.${system} .deadeye-admin ];
packages = with pkgs; [ just nodejs_18 node2nix ];
};
});
Expand Down
60 changes: 60 additions & 0 deletions web/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@

user nobody nobody;
daemon off;
error_log /dev/stdout;
pid /dev/null;

events {}

http {
include %MIME_TYPES% ;
access_log /dev/stdout;

proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;

server {
listen %NGINX_PORT%;

location / {
root %WEB_ROOT%;
index index.html;
try_files $uri $uri/ /index.html;
}

location /socket.io/ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_http_version 1.1;
proxy_pass http://admin:5000;
}

location /upload {
proxy_pass http://admin:5000;
}

location /stream/0/ {
proxy_pass http://daemon:5805/stream.mjpg;
}

location /stream/1/ {
proxy_pass http://daemon:5806/stream.mjpg;
}

location /stream/2/ {
proxy_pass http://daemon:5807/stream.mjpg;
}

location /stream/3/ {
proxy_pass http://daemon:5808/stream.mjpg;
}

location /stream/4/ {
proxy_pass http://daemon:5809/stream.mjpg;
}
}
}
62 changes: 0 additions & 62 deletions web/nginx/nginx.conf

This file was deleted.

0 comments on commit 66977e3

Please sign in to comment.