By recursional
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 example.com) shows up.
How can I change which site appears as the default for the IP address?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
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”
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:
adomain.com.conf
mydomain.com.conf
randomdomain.com.conf
Apache will use adomain.com.conf 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:
000-domain.com.conf
adomain.com.conf
mydomain.com.conf
randomdomain.com.conf
Instead of adomain.com.conf, Apache will use 000-domain.com.conf 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.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.