natbox.io

Guides / Multiple websites

Host multiple websites on one server

About 10 minutes per site. Debian or Ubuntu commands. Start with Host a website if this is your first one.

One server can run many websites. Visitors arrive on the same ports, and your web server picks the right site by domain name. This is the same idea our router uses to find your server, one step further.

1. Check how many domains your plan links

PlanDomainsThat is enough for
Free trial21 site with www
Nano31 site with www, plus 1 subdomain
Box105 sites with www
Box Plus, Box CPU2512 sites with www

Each name counts: example.com and www.example.com are two domains. Over IPv6 there is no such limit, but IPv4 visitors can only reach linked domains.

For every name, add it on the Domains tab and create the A, TXT and AAAA records it shows, as in the website guide. All your sites can point to the same IPv6 address.

3. Give each site its own folder and config

mkdir -p /var/www/site-one /var/www/site-two
echo "Site one" > /var/www/site-one/index.html
echo "Site two" > /var/www/site-two/index.html

Save as /etc/nginx/sites-available/site-one, and make a copy for each other site with its own names and folder:

server {
    listen 80;
    listen [::]:80;
    server_name site-one.example www.site-one.example;
    root /var/www/site-one;
    index index.html;
    location / {
        try_files $uri $uri/ =404;
    }
}
ln -s /etc/nginx/sites-available/site-one /etc/nginx/sites-enabled/
ln -s /etc/nginx/sites-available/site-two /etc/nginx/sites-enabled/
nginx -t && systemctl reload nginx

4. Add HTTPS to each site

apt install -y certbot python3-certbot-nginx
certbot --nginx -d site-one.example -d www.site-one.example
certbot --nginx -d site-two.example -d www.site-two.example

Each site gets its own certificate, and certbot renews them for you. Our router passes HTTPS through untouched, so this works the same as on any server.

5. Check each one

curl -I https://site-one.example
curl -I https://site-two.example

If one shows another site's page, check the server_name line in its config. If the domain does not reach your server at all, check it shows as verified on the Domains tab.

Good to know

Recommended plan: Box for up to 5 sites with www, or Box Plus for more.