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

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.

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.
Line #2, server_name , should ideally be your domain name, if the plan is to use one :-). Simply set it as:
server_name yourdomain.ext www.yourdomain.ext;
… where yourdomain.ext is yourdomain.com, yourdomain.net or the extension of your choosing. The above sets NGINX up to handle requests with and without the www.. You could also simply setup the same with:
server_name yourdomain.ext *.yourdomain.ext;
The * is referred to as a WildCard, meaning that any sub.yourdomain.ext will be routed to yourdomain.ext unless it exists, in which case the content for that sub-domain would be shown.
–
Beyond setting up NGINX, you’ll need to ensure that NGINX is started from the CLI (Command Line Interface) by issuing the following command:
service nginx start
–
Once that’s taken care of, you need to ensure that your domains DNS is properly setup. You’ll need your Droplet’s Public IP Address for this and you’ll need to create two A entries and CNAME entry. If you’ve set your domains DNS to DigitalOcean, you can make these changes through their control panel. If not, you’ll need to login to your domain registrars control panel and make the changes there.
–
The A entries will look like this:
A @ DROPLET_PUBLIC_IP
A * DROPLET_PUBLIC_IP
… where DROPLET_PUBLIC_IP = your Droplet’s Public IP Address.
The second A entry is the WildCard entry that coincides with your NGINX server block. If you don’t setup the server block using the WildCard, you can simply omit this one and only add the first.
–
The CNAME entry will look like this:
CNAME www yourdomain.ext
… simply replace yourdomain.ext with your actual domain name.
–
With those updates in place, DNS changes can take as little as a few minutes up to 24-48 hours to fully resolve, so don’t be alarmed if you aren’t able to access your domain immediately.