From c3b6a5549da4c5e4a3260cf75dc3a654015f5564 Mon Sep 17 00:00:00 2001 From: KalebSchmidlkofer Date: Sat, 23 Nov 2024 15:37:17 -0800 Subject: [PATCH] fix: finally got ssl working in nix environment #104 --- flake.nix | 39 ++++++++++++++++++++------------------- nix/buildsteps.sh | 6 ++++++ nix/caddyfile | 12 ++++++++++++ 3 files changed, 38 insertions(+), 19 deletions(-) create mode 100644 nix/caddyfile diff --git a/flake.nix b/flake.nix index 94b0db85c..2f5bfa8cc 100644 --- a/flake.nix +++ b/flake.nix @@ -17,12 +17,25 @@ export PATH=${pkgs.mariadb}/bin:$PATH export PATH=${pkgs.docker}/bin:$PATH export PATH=${pkgs.docker-compose}/bin:$PATH + export PATH=${pkgs.caddy}/bin:$PATH + + redis-server --daemonize yes redis-server --daemonize yes redis-cli ping + sleep 5 #mariadb-install-server #php artisan serve --host=127.0.0.1 --port=8000 + + # Clean up and create directories for MariaDB data + echo "Deleting MariaDB data directory" + rm -rf $(pwd)/nix/docker/maria/mariadb_data + + echo "Creating MariaDB data directory" + mkdir -p $(pwd)/nix/docker/maria/mariadb_data + bash ./nix/buildsteps.sh + redis-cli shutdown ''; # Development shell @@ -30,7 +43,7 @@ nativeBuildInputs = [ pkgs.php pkgs.phpPackages.composer - pkgs.nginx + pkgs.caddy pkgs.nodejs_20 pkgs.tmux pkgs.redis @@ -49,30 +62,17 @@ # Clean up and create directories for MariaDB data echo "Deleting MariaDB data directory" - #rm -rf $(pwd)/nix/docker/maria/mariadb_data + rm -rf $(pwd)/nix/docker/maria/mariadb_data + + echo "Creating MariaDB data directory" + mkdir -p $(pwd)/nix/docker/maria/mariadb_data + - #echo "Creating MariaDB data directory" - #mkdir -p $(pwd)/nix/docker/maria/mariadb_data echo "Run 'php artisan serve' to start the application." ''; }; - # NGINX configuration - nginxConfig = pkgs.writeText "nginx.conf" '' - server { - listen 80; - server_name localhost; - - location / { - proxy_pass http://127.0.0.1:8000; - 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; - } - } - ''; # Systemd services nixosConfigurations.default = pkgs.lib.nixosSystem { @@ -114,3 +114,4 @@ }; }; } + diff --git a/nix/buildsteps.sh b/nix/buildsteps.sh index cabafc708..4c4c2550b 100755 --- a/nix/buildsteps.sh +++ b/nix/buildsteps.sh @@ -93,12 +93,18 @@ php artisan p:node:configuration 1 >$(pwd)/nix/docker/wings/etc/config.yml docker-compose --project-directory ./nix/docker/wings up -d --force-recreate + + tmux new-session -s pyrodevelopment -d tmux send-keys -t pyrodevelopment 'npm run dev' C-m +tmux new-window -t pyrodevelopment +tmux send-keys -t pyrodevelopment 'caddy run --config ./nix/caddyfile' C-m + tmux new-window -t pyrodevelopment tmux send-keys -t pyrodevelopment 'php artisan serve' C-m + tmux attach-session -t pyrodevelopment tmux kill-session -t pyrodevelopment diff --git a/nix/caddyfile b/nix/caddyfile new file mode 100644 index 000000000..705edf7c7 --- /dev/null +++ b/nix/caddyfile @@ -0,0 +1,12 @@ +# Reverse proxy for pyrodactyl-panel +panel.localhost { + reverse_proxy 127.0.0.1:8000 + tls internal +} + +# Reverse proxy for pterodactyl-wings +wings.localhost { + reverse_proxy 127.0.0.1:8080 + tls internal +} +