Set primary domain for droplet IP address

April 27, 2017 1.8k views
Server Optimization Ubuntu 16.04

I have several domains on one droplet (a few simple static websites).

When I access the droplet IP address from a browser, one of those sites (let's call it shows up.

How can I change which site appears as the default for the IP address?

3 Answers


It depends on your web server.


Apache uses the first VirtualHost configuration it finds, after sorting numerically then alphabetically.

For example, if you have three VirtualHost configurations:

Apache will use as the default go-to when a request could not be otherwise sent to an actual domain on the server.

If, for example, you had a more mixed naming system such as:

Instead of, Apache will use since it's numbered.


NGINX uses a far better, user-configurable method. Add default_server to one (and only one) of your server blocks and it's now the default.

For example (covering both IPv4 and IPv6):

server {
    listen 80 default_server;
    listen [::]:80 default_server;

    root /path/to/home;

    location / {


So to fix this on Apache or NGINX, you'd simply create a new VirtualHost or Server Block and make sure it's numbered on Apache, or that it has default_server defined for NGINX.

Thanks for the response. That makes sense because the first domain that I added to the droplet is the one that appears, and the droplet is running Apache (on Ubuntu).

I can't find the location of the *.com.conf files to make changes though. Where would *.com.conf be located on Ubuntu? The files in /etc/apache2/ don't seem to have any info specific to my domains.

I should mention that I set up the domains via ServerPilot as separate "apps"

Anyone else know the answer?

Have another answer? Share your knowledge.