Commit 95728151 authored by Cameron Carney's avatar Cameron Carney

Added support to disable cron/workers; readded in SSL.

parent e2da4db5
......@@ -19,7 +19,7 @@ SSL_CERT="/etc/certs/cert.pem"
SSL_CERT_KEY="/etc/certs/cert.key"
# Disable's runtime workers & cronjob (this is useful if you want to run these in another container)
DISABLE_WORKER=false
DISABLE_WORKERS=false
##
# Panel Variables
......
......@@ -15,10 +15,18 @@ function init {
chown -R nginx:nginx /data/storage
fi
if [ ! -d /data/cache ]; then
mkdir -p /data/cache
chown -R nginx:nginx /data/cache
fi
# destroy links (or files) and recreate them
rm -rf storage
ln -s /data/storage storage
rm -rf bootstrap/cache
ln -s /data/cache bootstrap/cache
rm -rf .env
ln -s /data/pterodactyl.conf .env
}
......@@ -27,7 +35,7 @@ function init {
function startServer {
# Initial setup
if [ ! -e "/data/pterodactyl.conf" ]; then
if [ ! -e /data/pterodactyl.conf ]; then
echo "Running first time setup..."
# Generate base template
......@@ -56,10 +64,6 @@ function startServer {
php artisan db:seed --force
fi
rm -rf /var/run/supervisor.d/
mkdir /var/run/supervisor.d/
cp /etc/supervisor.d/service-files/* /var/run/supervisor.d/
# Allows Users to give MySQL/cache sometime to start up.
if [[ "${STARTUP_TIMEOUT}" -gt "0" ]]; then
echo "Starting Pterodactyl ${PANEL_VERSION} in ${STARTUP_TIMEOUT} seconds..."
......@@ -68,6 +72,28 @@ function startServer {
echo "Starting Pterodactyl ${PANEL_VERSION}..."
fi
if [ "${SSL}" == "true" ]; then
envsubst '${SSL_CERT},${SSL_CERT_KEY}' \
< /etc/nginx/templates/https.conf > /etc/nginx/conf.d/default.conf
else
echo "[Warning] Disabling HTTPS"
cat /etc/nginx/templates/http.conf > /etc/nginx/conf.d/default.conf
fi
# Copy service files to runtime files
rm -rf /var/run/supervisor.d/
mkdir /var/run/supervisor.d/
# Determine if workers should be enabled or not
if [ "${DISABLE_WORKERS}" != "true" ]; then
cp /etc/supervisor.d/runtime-files/* /var/run/supervisor.d/
else
echo "[Warning] Disabling Workers (pteroq & cron); It is recommended to keep these enabled unless you know what you are doing."
cp /etc/supervisor.d/runtime-files/nginx.ini \
/etc/supervisor.d/runtime-files/php-fpm.ini \
/var/run/supervisor.d/
fi
exec supervisord --nodaemon
}
......
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
multi_accept on;
use epoll;
}
http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
charset utf-8;
# Hide nginx version.
server_tokens off;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
aio on;
directio 512;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
# General config directory
include /etc/nginx/conf.d/*.conf;
}
\ No newline at end of file
server {
listen 80 default;
listen [::]:80 default;
location ^~ /.well-known {
alias /var/www/html/public/.well-known;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl http2 default;
listen [::]:443 ssl http2 default;
root /var/www/html/public;
index index.php;
charset utf-8;
ssl_certificate ${SSL_CERT};
ssl_certificate_key ${SSL_CERT_KEY};
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location = /favicon.ico { access_log off; log_not_found off; }
location = /robots.txt { access_log off; log_not_found off; }
access_log off;
error_log /data/storage/logs/nginx.app-error.log error;
# allow larger file uploads and longer script runtimes
client_max_body_size 100m;
client_body_timeout 120s;
sendfile off;
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PHP_VALUE "upload_max_filesize = 100M \n post_max_size=100M";
fastcgi_intercept_errors off;
fastcgi_buffer_size 16k;
fastcgi_buffers 4 16k;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
}
location ~ /\.ht {
deny all;
}
}
\ No newline at end of file
[include]
files = /var/run/supervisor.d/*.ini
\ No newline at end of file
[supervisord]
[include]
files = /var/run/supervisor.d/*.ini
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment