Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save TheDevFreak/94b702f4c802fd76e41880ef1da3d9e7 to your computer and use it in GitHub Desktop.
Save TheDevFreak/94b702f4c802fd76e41880ef1da3d9e7 to your computer and use it in GitHub Desktop.
Pterodactyl Panel Behind an NGINX Reverse Proxy
Your panel should run on port 80 (well whatever you want I suppose)
Node daemon port should be 443 (but still http) because it hard codes those ports into connection urls for websockets in the webui :/
Ensure you have `TRUSTED_PROXIES=proxyip` in your `/var/www/pterodactyl/.env` file.
server {
listen 443 ssl;
ssl on;
ssl_certificate /path/to/cert/fullchain.pem;
ssl_certificate_key /path/to/cert/key.pem;
server_name panel.domain.tld;
location / {
proxy_pass http://PANELIP_should_be_port_80/;
proxy_set_header Host $host;
client_max_body_size 50m;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_buffering off;
proxy_request_buffering off;
}
}
server {
listen 443 ssl;
ssl on;
ssl_certificate /path/to/cert/fullchain.pem;
ssl_certificate_key /path/to/cert/key.pem;
server_name node1.domain.tld;
location ~ ^\/api\/servers\/(?<serverid>.*)?\/ws$ {
proxy_pass http://node_ip:443/api/servers/$serverid/ws;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
client_max_body_size 50m;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_buffering off;
proxy_request_buffering off;
}
location / {
proxy_pass http://node_ip:443/;
proxy_set_header Host $host;
client_max_body_size 50m;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_redirect off;
proxy_buffering off;
proxy_request_buffering off;
}
}
@FlowerShopGuy
Copy link

FlowerShopGuy commented May 23, 2024

regix1
THANK YOU, IT'S WORKING

Just want to warning someone, your node should have a unic different A record even your node installed on the same IP as the panel, DON'T USE THE SAME DOMAIN NAME for node as for the pterodactyl game panel.
The first time i used same domain name for the panel and for the node and nothing is worked.
Should be.

panel.domain.com - ip: 92.222.100.100
node1.domain.com - ip: 92.222.100.100

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment