Report this

What is the reason for this report?

How to use wildcards for dynamic networking

Posted on February 16, 2021

I would like to make better use of wildcards for my droplets, but I can’t seem to get it right.

Ideally I would like all *-dev.domain.com sites to point to my DEV server, and *-staging to my staging server, without having to manually set this up each time.

Neither *.dev, *-dev or *_dev or *dev seem to behave as expected for newsite.dev.domain.com, newsite-dev.domain.com, newsite_dev.domain.com or newsitedev.domain.com.

Is there a way to utilise wildcard networking is this manner, other than *.domain.com.

Thanks!



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!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya,

Just came across this answer and decided to write some general guidelines for anyone who comes across this in the future despite the old question.

Appreciating your question on wildcards for droplets and domain handling, unfortunately, DNS does not support the types of wildcard patterns you mentioned. Wildcards in DNS work only on the “any subdomain” principle. You can set a record for *.domain.com, but not for more specific patterns like *-dev.domain.com or *-staging.domain.com.

However, DigitalOcean does offer Load Balancers and Floating IPs that can help distribute incoming traffic across multiple Droplets, which may be a good workaround for your need to serve different environments (e.g., dev, staging). You’ll have to configure your application to handle routing based on the subdomain.

For more information on DNS, you can check out the DigitalOcean DNS Documentation. For details on Load Balancers and Floating IPs, please check the Load Balancers Documentation and Floating IPs Documentation.

Hope that this helps!

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.