By newbie
Hi, is it possible to have 3 server blocks with following server name? server block 1
server_name example.com www.example.com;
server block 2
server_name demo.example.com;
server block 3
server_name *.example.com;
reason i want to have like this, my main site will have server block 1, a demo will have server block 2, server block 3 will maintain the configuration for all other sub-domains that my client will create from my application.
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!
Yes, Nginx uses the wildcard on anything not specified. http://nginx.org/en/docs/http/server_names.html
That’s definitely possible :-). Just make sure you have an A entry for the WildCard in your DNS Zone otherwise it won’t work properly.
For example:
A @ DROPLET_IP
A * DROPLET_IP
A www DROPLET_IP
A demo DROPLET_IP
Alternatively, you can use a CNAME for www:
A @ DROPLET_IP
A * DROPLET_IP
CNAME www example.com
A demo DROPLET_IP
Though for completeness, I’d recommend:
A @ DROPLET_IP
A * DROPLET_IP
A www DROPLET_IP
A demo DROPLET_IP
A www.demo DROPLET_IP
or
A @ DROPLET_IP
A * DROPLET_IP
CNAME www example.com
A demo DROPLET_IP
CNAME www.demo demo.example.com
… and changing:
server_name demo.example.com;
to
server_name demo.example.com www.demo.example.com;
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.