Skip to content

Commit

Permalink
fix: finally got ssl working in nix environment #104
Browse files Browse the repository at this point in the history
  • Loading branch information
naterfute committed Nov 23, 2024
1 parent 6757e9d commit c3b6a55
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 19 deletions.
39 changes: 20 additions & 19 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,33 @@
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
devShell.x86_64-linux = pkgs.mkShell {
nativeBuildInputs = [
pkgs.php
pkgs.phpPackages.composer
pkgs.nginx
pkgs.caddy
pkgs.nodejs_20
pkgs.tmux
pkgs.redis
Expand All @@ -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 {
Expand Down Expand Up @@ -114,3 +114,4 @@
};
};
}

6 changes: 6 additions & 0 deletions nix/buildsteps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 12 additions & 0 deletions nix/caddyfile
Original file line number Diff line number Diff line change
@@ -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
}

0 comments on commit c3b6a55

Please sign in to comment.