add e11sync-caddy
This commit is contained in:
parent
9870e5c239
commit
c3d052ad01
5
Makefile
5
Makefile
@ -11,7 +11,10 @@ format:
|
||||
run:
|
||||
app/manage.py runserver
|
||||
|
||||
# "Like production". Run with "run-caddy".
|
||||
.PHONY: run-gunicorn
|
||||
run-gunicorn:
|
||||
nix run .#e11sync-gunicorn
|
||||
|
||||
.PHONY: run-caddy
|
||||
run-caddy:
|
||||
nix run .#e11sync-caddy
|
||||
|
@ -38,7 +38,7 @@ SECRET_KEY = _SECRET_KEY
|
||||
|
||||
DEBUG = _DEBUG
|
||||
|
||||
ALLOWED_HOSTS = ["127.0.0.1"]
|
||||
ALLOWED_HOSTS = ["127.0.0.1", "localhost"]
|
||||
|
||||
INTERNAL_IPS = ["127.0.0.1"]
|
||||
|
||||
@ -140,7 +140,7 @@ COMPRESS_FILTERS = {
|
||||
}
|
||||
|
||||
COMPRESS_PRECOMPILERS = (
|
||||
('text/x-scss', 'sass {infile} {outfile}'),
|
||||
('text/x-scss', 'sass --no-source-map {infile} {outfile}'),
|
||||
)
|
||||
|
||||
DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'
|
||||
|
27
flake.nix
27
flake.nix
@ -44,11 +44,16 @@
|
||||
|
||||
e11sync-static = pkgs.callPackage ./pkgs/e11sync-static.nix {};
|
||||
|
||||
e11sync-caddy = pkgs.callPackage ./pkgs/e11sync-caddy.nix {
|
||||
inherit e11sync-static;
|
||||
};
|
||||
|
||||
e11sync = pkgs.callPackage ./pkgs/e11sync.nix {inherit geoip-mmdb;};
|
||||
in {
|
||||
packages = {
|
||||
inherit geoip-mmdb;
|
||||
inherit e11sync-static;
|
||||
inherit e11sync-caddy;
|
||||
inherit e11sync;
|
||||
};
|
||||
|
||||
@ -89,6 +94,28 @@
|
||||
exec ${e11sync}/bin/e11sync-gunicorn
|
||||
'');
|
||||
};
|
||||
e11sync-caddy = {
|
||||
type = "app";
|
||||
name = "e11sync-caddy";
|
||||
program = let
|
||||
caddyFile = pkgs.writeTextFile {
|
||||
name = "Caddyfile";
|
||||
text = ''
|
||||
{
|
||||
http_port 8001
|
||||
auto_https off
|
||||
debug
|
||||
}
|
||||
:8001
|
||||
|
||||
${builtins.readFile "${e11sync-caddy}"}
|
||||
'';
|
||||
};
|
||||
in
|
||||
toString (pkgs.writeShellScript "wrapper" ''
|
||||
exec ${pkgs.caddy}/bin/caddy run --config ${caddyFile} --adapter caddyfile
|
||||
'');
|
||||
};
|
||||
};
|
||||
|
||||
devShells.default = pkgs.mkShellNoCC {
|
||||
|
22
pkgs/e11sync-caddy.nix
Normal file
22
pkgs/e11sync-caddy.nix
Normal file
@ -0,0 +1,22 @@
|
||||
{
|
||||
writeTextFile,
|
||||
e11sync-static,
|
||||
gunicornPort ? 8002,
|
||||
}:
|
||||
writeTextFile {
|
||||
name = "e11sync-caddy";
|
||||
text = ''
|
||||
header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload"
|
||||
header /static/CACHE/* Cache-Control "public, max-age=31536000, immutable"
|
||||
|
||||
route /static/* {
|
||||
uri strip_prefix /static
|
||||
file_server * {
|
||||
root ${e11sync-static}
|
||||
precompressed br gzip
|
||||
}
|
||||
}
|
||||
|
||||
reverse_proxy http://127.0.0.1:${toString gunicornPort}
|
||||
'';
|
||||
}
|
@ -6,7 +6,7 @@
|
||||
python3Packages,
|
||||
libmaxminddb,
|
||||
dart-sass,
|
||||
gunicornPort ? 8001,
|
||||
gunicornPort ? 8002,
|
||||
database-path ? null,
|
||||
geoip-mmdb,
|
||||
}:
|
||||
|
Loading…
Reference in New Issue
Block a user