Connecting a domain to a web server i host in pterodactyl

Guide to Connecting Your Custom Domain to a Self-Hosted Web Server Managed with Pterodactyl

Setting up a personal or business website on your own server can be an empowering experience. If you’re hosting your website on a VPS running Pterodactyl, and want to connect a custom domain, this guide will walk you through the process, including troubleshooting common issues such as misconfigurations or security flags.

Prerequisites:

  • A Virtual Private Server (VPS) with Pterodactyl installed
  • A registered domain name (purchased via providers like GoDaddy)
  • DNS management access for your domain
  • Cloudflare account for DNS proxying and security
  • Nginx installed and configured on your VPS

Step 1: Prepare Your Domain DNS Settings

First, ensure your domainโ€™s DNS records point correctly to your VPS IP address. Since you are using Cloudflare, follow these steps:

  • Log in to your Cloudflare dashboard.
  • Select your domain.
  • Navigate to DNS management.
  • Add an A record pointing to your VPSโ€™s public IP address; for example:

    | Type | Name | Content | TTL | Proxy Status |
    |——-|———–|——————|—–|————–|
    | A | @ | YOUR_VPS_IP | Auto | Proxy (orange cloud) |

  • To ensure your web traffic is proxied through Cloudflare (which adds security and CDN features), keep the proxy status active.


Step 2: Configure Nginx on Your VPS

Your VPS uses Nginx as a reverse proxy to serve your website. Verify your configuration:

  • Locate your Nginx site configuration file, typically found in /etc/nginx/sites-available/.
  • Create or edit the configuration to include your domain, for example:

“`nginx
server {
listen 80;
server_name yourdomain.com www.yourdomain.com;

location / {
    proxy_pass http://localhost:PORT;  # Port where your web app is hosted
    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;
}

}
“`

  • Reload Nginx to apply changes:

bash
sudo nginx -t
sudo systemctl reload nginx



Leave a Reply

Your email address will not be published. Required fields are marked *