You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

单域名+两组域名服务器(Glue Records)搭建多VPS站点求助

Alright, let's work through this step by step—you already got the glue records set up, which is a big win! Here's how to get those four domains hosted on your two VPSes without hitting more roadblocks:

Step 1: Finalize DNS Configuration

Glue records just lay the groundwork; now we need to tie your target domains to your VPS IPs properly:

  • If one-bar.com, two-bar.com, three-bar.com, and four-bar.com are separately registered domains, head to each of their registrars and set their NS (Nameserver) records to point to your custom nameservers under foo.com (e.g., ns1.foo.com and ns2.foo.com). The glue records you added earlier ensure DNS resolvers know the IPs for these foo.com nameservers, so this will resolve correctly.
  • Next, on your DNS server (I assume you're running one on vps1/vps2 for redundancy—if not, pick one VPS to host the primary DNS), create zone files for each domain:
    • For one-bar.com and two-bar.com: Add an A record pointing to 192.0.0.1 (vps1's IP). You can also add a CNAME record for www.one-bar.com pointing to one-bar.com if you want the www subdomain to work.
    • For three-bar.com and four-bar.com: Add an A record pointing to 192.0.0.2 (vps2's IP).
  • Verify DNS propagation with quick terminal checks:
    dig one-bar.com A
    dig ns one-bar.com
    
    Give it 10-30 minutes for records to propagate if they don't show up immediately.
Step 2: Configure Web Servers on Each VPS

I'll use Nginx here (it's lightweight and widely supported)—the logic translates to Apache too, just adjust config file paths and syntax.

On vps1 (192.0.0.1)

  1. Install Nginx if you haven't already:
    sudo apt update && sudo apt install nginx
    
  2. Create a server block config for one-bar.com:
    sudo nano /etc/nginx/sites-available/one-bar.com
    
    Paste this basic config (tweak the root path or index files to match your project):
    server {
        listen 80;
        server_name one-bar.com www.one-bar.com;
    
        root /var/www/one-bar.com/html;
        index index.html index.htm;
    
        location / {
            try_files $uri $uri/ =404;
        }
    }
    
  3. Repeat the process for two-bar.com—just update the server_name and root directory (e.g., /var/www/two-bar.com/html).
  4. Enable the server blocks by linking them to the sites-enabled directory:
    sudo ln -s /etc/nginx/sites-available/one-bar.com /etc/nginx/sites-enabled/
    sudo ln -s /etc/nginx/sites-available/two-bar.com /etc/nginx/sites-enabled/
    
  5. Test for config errors, then restart Nginx:
    sudo nginx -t
    sudo systemctl restart nginx
    
  6. Create website directories and add a test page:
    sudo mkdir -p /var/www/one-bar.com/html
    sudo chown -R $USER:$USER /var/www/one-bar.com/html
    echo "<h1>Hello from one-bar.com!</h1>" > /var/www/one-bar.com/html/index.html
    
    Do the same for two-bar.com.

On vps2 (192.0.0.2)

Follow the exact same steps as vps1, but for three-bar.com and four-bar.com. Since you're configuring this directly on vps2, the server blocks will automatically bind to its IP.

Step 3: Lock Down Firewalls & Add HTTPS
  • Open ports 80 (HTTP) and 443 (HTTPS) on both VPSes to allow web traffic:
    sudo ufw allow 'Nginx Full'
    
  • For HTTPS (highly recommended for security), use Certbot to get free SSL certificates:
    sudo apt install certbot python3-certbot-nginx
    sudo certbot --nginx
    
    Follow the prompts—Certbot will automatically update your Nginx configs to redirect HTTP to HTTPS.
Quick Troubleshooting Tips
  • If domains aren't loading, wait for full DNS propagation (can take up to 24 hours, but usually faster). Use dig +trace one-bar.com to spot where resolution fails.
  • Check if Nginx is running: sudo systemctl status nginx
  • Verify your VPS IPs are reachable: curl http://192.0.0.1 should load the default Nginx page or your test content.

内容的提问来源于stack exchange,提问作者Pankil Joshi

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.19 10:25:18