Files
pterodactyl-panel/.github/docker/default_ssl.conf
T
2026-10-06 20:11:59 -04:00

127 lines
4.5 KiB
Plaintext

# If using Ubuntu this file should be placed in:
# /etc/nginx/sites-available/
#
server {
listen 80;
server_name <domain>;
return 301 https://$server_name$request_uri;
}
server {
listen 443 ssl;
http2 on;
server_name <domain>;
root /app/public;
index index.php;
access_log /var/log/nginx/pterodactyl.app-access.log;
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;
# strengthen ssl security
ssl_certificate /etc/letsencrypt/live/<domain>/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/<domain>/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;
ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384;
# See the link below for more SSL information:
# https://raymii.org/s/tutorials/Strong_SSL_Security_On_nginx.html
#
# ssl_dhparam /etc/ssl/certs/dhparam.pem;
# Add headers to serve security related headers
add_header Strict-Transport-Security "max-age=15768000; preload;";
add_header X-Content-Type-Options nosniff;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header Content-Security-Policy "frame-ancestors 'self'";
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location ^~ /assets/ {
# Compress static build output only. Dynamic responses stay uncompressed so
# secrets in them cannot leak through compression side channels (BREACH).
gzip on;
gzip_comp_level 5;
gzip_min_length 1024;
gzip_proxied any;
gzip_vary on;
gzip_types text/css text/javascript application/javascript application/json image/svg+xml;
location ~ /\. {
deny all;
}
# Extension files are third-party content on the panel's origin. The sandbox stops a
# file opened directly (an SVG, say) from running script as the panel. ^~ skips the
# regex locations above, so dotfiles are denied again here. add_header at this level
# drops the server-level headers, so they are repeated.
location ^~ /assets/extensions/ {
add_header Strict-Transport-Security "max-age=15768000; preload;";
add_header X-Content-Type-Options nosniff always;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header Content-Security-Policy "sandbox; frame-ancestors 'self'" always;
location ~ /\. {
deny all;
}
# A sandbox policy would stop these from starting as workers, and a script never
# renders as a page, so it gets the server-level headers only.
location ~ \.m?js$ {
add_header Strict-Transport-Security "max-age=15768000; preload;";
add_header X-Content-Type-Options nosniff always;
add_header X-XSS-Protection "1; mode=block";
add_header X-Robots-Tag none;
add_header Content-Security-Policy "frame-ancestors 'self'";
try_files $uri =404;
}
try_files $uri =404;
}
# Build output is content-hashed, so it never changes under the same name.
# Extension assets keep their own names and are revalidated as usual. This uses
# `expires` rather than add_header so the server-level security headers still apply.
location ~ "^/assets/(?!extensions/).+\.[A-Za-z0-9_-]{8}\.(?:js|css|svg|woff2?)$" {
expires 1y;
try_files $uri =404;
}
try_files $uri =404;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
include fastcgi_params;
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;
include /etc/nginx/fastcgi_params;
}
location ~ /\. {
deny all;
}
}