2024-05-03 16:58:45 -04:00
|
|
|
{
|
|
|
|
|
pkgs,
|
|
|
|
|
config,
|
|
|
|
|
...
|
2024-05-03 18:13:08 -04:00
|
|
|
}: let
|
|
|
|
|
wings = pkgs.stdenv.mkDerivation {
|
|
|
|
|
name = "wings";
|
|
|
|
|
|
|
|
|
|
src = pkgs.fetchurl {
|
|
|
|
|
name = "wings";
|
|
|
|
|
url = "https://github.com/pterodactyl/wings/releases/latest/download/wings_linux_amd64";
|
2024-05-03 18:13:55 -04:00
|
|
|
sha256 = "sha256-S8vTpxvtmv7TfRMpgKxVPkvTmji1rlPEd9ApM3Rt6FY=";
|
2024-05-03 18:13:08 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
phases = ["installPhase"];
|
|
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
|
install -D $src $out/bin/wings
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
in {
|
2024-05-03 16:28:54 -04:00
|
|
|
services.mysql = {
|
|
|
|
|
enable = true;
|
|
|
|
|
package = pkgs.mariadb;
|
|
|
|
|
};
|
|
|
|
|
|
2024-05-03 16:58:45 -04:00
|
|
|
systemd.timers."p_artisan-run" = {
|
|
|
|
|
wantedBy = ["timers.target"];
|
|
|
|
|
timerConfig = {
|
|
|
|
|
OnBootSec = "1m";
|
|
|
|
|
OnUnitActiveSec = "1m";
|
|
|
|
|
Unit = "p_artisan-run.service";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
systemd.services."p_artisan-run" = {
|
|
|
|
|
script = ''
|
|
|
|
|
${pkgs.php}/bin/php /var/www/pterodactyl/artisan schedule:run >> /dev/null 2>&1
|
|
|
|
|
'';
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
Type = "oneshot";
|
|
|
|
|
User = "root";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2024-05-03 18:22:10 -04:00
|
|
|
environment.etc."pterodactyl/config.yml".text = ''
|
|
|
|
|
debug: false
|
|
|
|
|
uuid: d9ba8bb8-8c2f-4150-aadf-ee940d244246
|
|
|
|
|
token_id: rJuftwFA5ojnP9eW
|
|
|
|
|
token: Qm6PyNvu1tKXMaqwzPQzfJuMdezdTLWh8DJVjrpWIDDVOitm2wIz04tJ35Ey1txN
|
|
|
|
|
api:
|
|
|
|
|
host: 0.0.0.0
|
|
|
|
|
port: 6969
|
|
|
|
|
ssl:
|
|
|
|
|
enabled: true
|
2024-05-03 18:30:20 -04:00
|
|
|
|
|
|
|
|
cert: /var/lib/acme/node.nyc.zackmyers.io/fullchain.pem
|
|
|
|
|
key: /var/lib/acme/node.nyc.zackmyers.io/key.pem
|
2024-05-03 18:22:10 -04:00
|
|
|
upload_limit: 100
|
|
|
|
|
system:
|
|
|
|
|
data: /var/lib/pterodactyl/volumes
|
|
|
|
|
sftp:
|
|
|
|
|
bind_port: 2022
|
|
|
|
|
allowed_mounts: []
|
|
|
|
|
remote: 'https://pterodactyl.zackmyers.io'
|
|
|
|
|
'';
|
|
|
|
|
|
2024-05-03 18:13:08 -04:00
|
|
|
systemd.services."wings" = {
|
|
|
|
|
after = ["docker.service"];
|
|
|
|
|
requires = ["docker.service"];
|
|
|
|
|
partOf = ["docker.service"];
|
|
|
|
|
script = ''
|
2024-05-03 18:34:11 -04:00
|
|
|
#!/usr/bin/env bash
|
2024-05-03 18:13:08 -04:00
|
|
|
${wings}/bin/wings
|
|
|
|
|
'';
|
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
User = "root";
|
|
|
|
|
WorkingDirectory = "/etc/pterodactyl";
|
|
|
|
|
LimitNOFILE = 4096;
|
|
|
|
|
PIDFile = /var/run/wings/daemon.pid;
|
|
|
|
|
Restart = "on-failure";
|
|
|
|
|
StartLimitInterval = 180;
|
|
|
|
|
StartLimitBurst = 30;
|
|
|
|
|
RestartSec = "5s";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2024-05-03 16:58:45 -04:00
|
|
|
systemd.services."p_queue-worker" = {
|
|
|
|
|
after = ["redis.service"];
|
|
|
|
|
wantedBy = ["multi-user.target"];
|
|
|
|
|
script = ''
|
|
|
|
|
${pkgs.php} /var/www/pterodactyl/artisan queue:work --queue=high,standard,low --sleep=3 --tries=3
|
|
|
|
|
'';
|
|
|
|
|
serviceConfig = {
|
|
|
|
|
User = "nginx";
|
|
|
|
|
Group = "nginx";
|
|
|
|
|
Restart = "always";
|
|
|
|
|
StartLimitInterval = 180;
|
|
|
|
|
StartLimitBurst = 30;
|
|
|
|
|
RestartSec = "5s";
|
|
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
services.nginx.virtualHosts."pterodactyl.zackmyers.io" = {
|
2024-05-03 17:17:08 -04:00
|
|
|
forceSSL = true;
|
|
|
|
|
enableACME = true;
|
2024-05-03 16:58:45 -04:00
|
|
|
root = "/var/www/pterodactyl/public";
|
|
|
|
|
|
|
|
|
|
locations."/".extraConfig = ''
|
|
|
|
|
try_files $uri $uri/ /index.php?$query_string;
|
|
|
|
|
'';
|
|
|
|
|
locations."/favicon.ico".extraConfig = ''
|
|
|
|
|
access_log off; log_not_found off;
|
2024-05-03 17:03:59 -04:00
|
|
|
'';
|
|
|
|
|
locations."/robots.txt".extraConfig = ''
|
2024-05-03 16:58:45 -04:00
|
|
|
access_log off; log_not_found off;
|
|
|
|
|
'';
|
|
|
|
|
locations."~ \\.php$".extraConfig = ''
|
|
|
|
|
fastcgi_split_path_info ^(.+\.php)(/.+)$;
|
2024-05-03 17:34:02 -04:00
|
|
|
fastcgi_pass unix:${config.services.phpfpm.pools.pterodactyl.socket};
|
2024-05-03 16:58:45 -04:00
|
|
|
fastcgi_index index.php;
|
2024-05-03 17:25:14 -04:00
|
|
|
include ${pkgs.nginx}/conf/fastcgi_params;
|
2024-05-03 16:58:45 -04:00
|
|
|
fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
|
|
|
|
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
|
|
|
|
fastcgi_param HTTP_PROXY "";
|
|
|
|
|
fastcgi_intercept_errors off;
|
|
|
|
|
fastcgi_buffer_size 16k;
|
|
|
|
|
fastcgi_buffers 4 16k;
|
|
|
|
|
fastcgi_connect_timeout 300;
|
|
|
|
|
fastcgi_send_timeout 300;
|
|
|
|
|
fastcgi_read_timeout 300;
|
2024-05-03 18:13:08 -04:00
|
|
|
|
|
|
|
|
proxy_set_header X-Real-IP $remote_addr;
|
|
|
|
|
proxy_set_header Host $host;
|
|
|
|
|
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
|
|
|
|
proxy_set_header X-Forwarded-Proto $scheme;
|
|
|
|
|
proxy_redirect off;
|
|
|
|
|
proxy_buffering off;
|
|
|
|
|
proxy_request_buffering off;
|
2024-05-03 16:58:45 -04:00
|
|
|
'';
|
|
|
|
|
|
2024-05-03 17:10:15 -04:00
|
|
|
locations."~ /\\.ht".extraConfig = ''
|
2024-05-03 16:58:45 -04:00
|
|
|
deny all;
|
|
|
|
|
'';
|
|
|
|
|
|
|
|
|
|
extraConfig = ''
|
2024-05-03 17:15:52 -04:00
|
|
|
index index.html index.htm index.php;
|
|
|
|
|
charset utf-8;
|
|
|
|
|
|
2024-05-03 16:58:45 -04:00
|
|
|
access_log off;
|
|
|
|
|
error_log /var/log/nginx/pterodactyl.app-error.log error;
|
|
|
|
|
|
|
|
|
|
# allow larger file uploads and longer script runtimes
|
|
|
|
|
client_max_body_size 100m;
|
|
|
|
|
client_body_timeout 120s;
|
|
|
|
|
|
|
|
|
|
sendfile off;
|
|
|
|
|
'';
|
|
|
|
|
};
|
|
|
|
|
|
2024-05-03 17:34:02 -04:00
|
|
|
services.phpfpm = {
|
|
|
|
|
phpOptions = ''
|
2024-05-03 17:35:36 -04:00
|
|
|
extension=${pkgs.php81Extensions.openssl}/lib/php/extensions/openssl.so
|
|
|
|
|
extension=${pkgs.php81Extensions.gd}/lib/php/extensions/gd.so
|
2024-05-03 17:44:27 -04:00
|
|
|
extension=${pkgs.php81Extensions.mysqlnd}/lib/php/extensions/mysqlnd.so
|
2024-05-03 17:35:36 -04:00
|
|
|
extension=${pkgs.php81Extensions.mbstring}/lib/php/extensions/mbstring.so
|
|
|
|
|
extension=${pkgs.php81Extensions.tokenizer}/lib/php/extensions/tokenizer.so
|
|
|
|
|
extension=${pkgs.php81Extensions.bcmath}/lib/php/extensions/bcmath.so
|
|
|
|
|
extension=${pkgs.php81Extensions.xml}/lib/php/extensions/xml.so
|
|
|
|
|
extension=${pkgs.php81Extensions.dom}/lib/php/extensions/dom.so
|
|
|
|
|
extension=${pkgs.php81Extensions.curl}/lib/php/extensions/curl.so
|
|
|
|
|
extension=${pkgs.php81Extensions.zip}/lib/php/extensions/zip.so
|
2024-05-03 17:34:02 -04:00
|
|
|
'';
|
|
|
|
|
pools.pterodactyl = {
|
2024-05-03 17:46:57 -04:00
|
|
|
user = config.services.nginx.user;
|
2024-05-03 17:35:36 -04:00
|
|
|
phpPackage = pkgs.php81;
|
2024-05-03 17:34:02 -04:00
|
|
|
settings = {
|
|
|
|
|
"pm" = "dynamic";
|
|
|
|
|
"listen.owner" = config.services.nginx.user;
|
|
|
|
|
"pm.max_children" = 5;
|
|
|
|
|
"pm.start_servers" = 2;
|
|
|
|
|
"pm.min_spare_servers" = 1;
|
|
|
|
|
"pm.max_spare_servers" = 3;
|
|
|
|
|
"pm.max_requests" = 500;
|
|
|
|
|
};
|
2024-05-03 16:58:45 -04:00
|
|
|
};
|
|
|
|
|
};
|
|
|
|
|
|
2024-05-03 16:28:54 -04:00
|
|
|
services.redis = {
|
|
|
|
|
enable = true;
|
|
|
|
|
};
|
|
|
|
|
}
|