{"id":9628,"date":"2022-09-07T16:47:11","date_gmt":"2022-09-07T11:17:11","guid":{"rendered":"https:\/\/www.skynats.com\/?p=9628"},"modified":"2023-06-15T17:09:06","modified_gmt":"2023-06-15T11:39:06","slug":"add-subdomain-with-nginx-digitalocean","status":"publish","type":"post","link":"https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/","title":{"rendered":"Add Subdomain With NGINX DigitalOcean"},"content":{"rendered":"\n<p>With the help of this article, adding a subdomain with NGINX in DigitalOcean became simple. With our <a href=\"https:\/\/www.skynats.com\/digitalocean-management\/\" target=\"_blank\" rel=\"noreferrer noopener\">DigitalOcean Support Services<\/a>, <em><strong>Skynats<\/strong><\/em> can handle your DigitalOcean issues.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-adding-a-subdomain-with-nginx-in-digitalocean\">Adding a subdomain with NGINX in DigitalOcean<\/h2>\n\n\n\n<p>Nginx is one of the most widely used web servers in the world, hosting some of the busiest and greatest websites on the internet. It is a straightforward choice that can act as a reverse proxy, mail server, or web server. The most user-friendly method of configuring a fast, safe, and reliable NGINX server is through DigitalOcean&#8217;s NGINXConfig.<\/p>\n\n\n\n<p>We&#8217;ll go over how to add a subdomain with NGINX on DigitalOcean in this article.<\/p>\n\n\n\n<p><strong>Pre-requisites<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>An Ubuntu server on DigitalOcean<\/li><li>NGINX and SSL on DigitalOcean&nbsp;<\/li><\/ul>\n\n\n\n<p><strong>Following are the steps:<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Make an &#8220;A&#8221; record first for the subdomain.<\/li><li>Then make an index file and subdomain directory.<\/li><li>Make an NGINX server block for the subdomain as well.<\/li><li>For security, add an SSL certificate right away.<\/li><li>&nbsp;Lastly, access the subdomain.<\/li><\/ul>\n\n\n\n<p>Let&#8217;s go over each step in detail.<\/p>\n\n\n\n<p><strong>1. Make an &#8220;A&#8221; record first for the subdomain:<\/strong><\/p>\n\n\n\n<p>Go to the DNS settings page to access the records that contain the primary domain DNS settings. Afterward, by including only the subdomain portion in the Enter Name field, add an A record with a subdomain.<\/p>\n\n\n\n<p><strong>2. Then make an index file and a subdomain directory:<\/strong><\/p>\n\n\n\n<p>Create the subdomain first, then add the index file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>subdomain_dir=\/var\/www\/apps.example.com\r\n# Create directory\r\nsudo mkdir $subdomain_dir\r\n# Create index.html\r\nsudo touch $subdomain_dir\/index.html<\/code><\/pre>\n\n\n\n<p>The contents of the index file can be modified. The content appears as follows:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&lt;!DOCTYPE html>\r\n&lt;html>\r\n&lt;head>\r\n&lt;title>Welcome to Example Appstore!&lt;\/title>\r\n&lt;style>\r\n    body {\r\n        width: 35em;\r\n        margin: 0 auto;\r\n        font-family: Tahoma, Verdana, Arial, sans-serif;\r\n    }\r\n&lt;\/style>\r\n&lt;\/head>\r\n&lt;body>\r\n&lt;h1>Welcome to Example Appstore!&lt;\/h1>\r\n&lt;p>This site is under active development.&lt;\/p>\r\n\r\n&lt;h2>Related Websites&lt;\/h2>\r\n&lt;a href = \"https:\/\/www.datanovia.com\">Datanovia&lt;\/a>&lt;br\/>\r\n&lt;\/body>\r\n&lt;\/html><\/code><\/pre>\n\n\n\n<p><strong>3. Make an NGINX server block for the subdomain as well:<\/strong><\/p>\n\n\n\n<p>The subdomain is now enabled on the NGINX server.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># 1. Copy the default subdomain configuration\r\nmysubdomain=\"apps.example.com\"\r\nsudo cp \/etc\/nginx\/sites-available\/default \/etc\/nginx\/sites-available\/$mysubdomain\r\nsudo ln -s \/etc\/nginx\/sites-available\/$mysubdomain \/etc\/nginx\/sites-enabled\/$mysubdomain\r\n  \r\n# 2. Open the config file\r\nsudo nano \/etc\/nginx\/sites-available\/$mysubdomain\r\n  \r\n# 3. Edit the file\r\n# The content will look like this\r\nserver {\r\n        listen 80;\r\n        listen &#91;::]:80;\r\n        root \/var\/www\/apps;\r\n        index index.html;\r\n        server_name apps.example.com;\r\n}\r\n  \r\n# 4. Restart NGINX\r\nsudo service nginx restart<\/code><\/pre>\n\n\n\n<p><strong>4. For security, add an SSL certificate right away:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Obtain an SSL Certificate\r\nsudo certbot --nginx -d $mysubdomain<\/code><\/pre>\n\n\n\n<p><strong>5. Lastly, access the subdomain:<\/strong><\/p>\n\n\n\n<p>Go to the subdomain at this point.<\/p>\n\n\n\n<p><\/p>\n\n\n\n<p><strong>Conclusion<\/strong><\/p>\n\n\n\n<p>In this article, we offer a straightforward technique developed by our tech team for adding a subdomain with NGINX in DigitalOcean.<\/p>\n\n\n\n<p>Are you looking for an answer to another query?\u00a0<a href=\"https:\/\/www.skynats.com\/contact-us\/\" target=\"_blank\" rel=\"noreferrer noopener\"><em>Contact<\/em><\/a>\u00a0our technical support team.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>With the help of this article, adding a subdomain with NGINX in DigitalOcean became simple. With our DigitalOcean Support Services, Skynats can handle your DigitalOcean issues. Adding a subdomain with NGINX in DigitalOcean Nginx is one of the most widely used web servers in the world, hosting some of the busiest and greatest websites on [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-9628","post","type-post","status-publish","format-standard","hentry","category-blog"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v25.9 (Yoast SEO v27.5) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Add Subdomain With NGINX DigitalOcean | Skynats<\/title>\n<meta name=\"description\" content=\"Adding a subdomain with NGINX in DigitalOcean is simple. Make an &quot;A&quot; record for the subdomain. Then Make an index file and subdomain directory.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Add Subdomain With NGINX DigitalOcean\" \/>\n<meta property=\"og:description\" content=\"Adding a subdomain with NGINX in DigitalOcean is simple. Make an &quot;A&quot; record for the subdomain. Then Make an index file and subdomain directory.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/\" \/>\n<meta property=\"og:site_name\" content=\"Server Management Services | Cloud Management | Skynats\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/skynats\" \/>\n<meta property=\"article:published_time\" content=\"2022-09-07T11:17:11+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2023-06-15T11:39:06+00:00\" \/>\n<meta name=\"author\" content=\"Arjun N\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@skynatstech\" \/>\n<meta name=\"twitter:site\" content=\"@skynatstech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Arjun N\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/add-subdomain-with-nginx-digitalocean\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/add-subdomain-with-nginx-digitalocean\\\/\"},\"author\":{\"name\":\"Arjun N\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#\\\/schema\\\/person\\\/2428d280a8b32a1fbd909b1411e32fb7\"},\"headline\":\"Add Subdomain With NGINX DigitalOcean\",\"datePublished\":\"2022-09-07T11:17:11+00:00\",\"dateModified\":\"2023-06-15T11:39:06+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/add-subdomain-with-nginx-digitalocean\\\/\"},\"wordCount\":326,\"publisher\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#organization\"},\"articleSection\":[\"Blog\"],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/add-subdomain-with-nginx-digitalocean\\\/\",\"url\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/add-subdomain-with-nginx-digitalocean\\\/\",\"name\":\"Add Subdomain With NGINX DigitalOcean | Skynats\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#website\"},\"datePublished\":\"2022-09-07T11:17:11+00:00\",\"dateModified\":\"2023-06-15T11:39:06+00:00\",\"description\":\"Adding a subdomain with NGINX in DigitalOcean is simple. Make an \\\"A\\\" record for the subdomain. Then Make an index file and subdomain directory.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/add-subdomain-with-nginx-digitalocean\\\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.skynats.com\\\/blog\\\/add-subdomain-with-nginx-digitalocean\\\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/add-subdomain-with-nginx-digitalocean\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Add Subdomain With NGINX DigitalOcean\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/\",\"name\":\"Server Management Services | Cloud Management | Skynats\",\"description\":\"Server Management and Cloud Management\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#organization\",\"name\":\"Skynats Technologies\",\"url\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/Sknats-Logo-New-whole.png\",\"contentUrl\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/wp-content\\\/uploads\\\/2021\\\/08\\\/Sknats-Logo-New-whole.png\",\"width\":989,\"height\":367,\"caption\":\"Skynats Technologies\"},\"image\":{\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/skynats\",\"https:\\\/\\\/x.com\\\/skynatstech\",\"https:\\\/\\\/www.instagram.com\\\/skynatstech\\\/\",\"https:\\\/\\\/www.linkedin.com\\\/company\\\/skynats-technologies\",\"https:\\\/\\\/www.youtube.com\\\/channel\\\/UCvTAjrFJ4_E2MJKwlDHomlg\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.skynats.com\\\/blog\\\/#\\\/schema\\\/person\\\/2428d280a8b32a1fbd909b1411e32fb7\",\"name\":\"Arjun N\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e0f4d2489abeea1769beb944d2258c862259b62ff26853075066ca8ad37e3333?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e0f4d2489abeea1769beb944d2258c862259b62ff26853075066ca8ad37e3333?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/e0f4d2489abeea1769beb944d2258c862259b62ff26853075066ca8ad37e3333?s=96&d=mm&r=g\",\"caption\":\"Arjun N\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Add Subdomain With NGINX DigitalOcean | Skynats","description":"Adding a subdomain with NGINX in DigitalOcean is simple. Make an \"A\" record for the subdomain. Then Make an index file and subdomain directory.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/","og_locale":"en_US","og_type":"article","og_title":"Add Subdomain With NGINX DigitalOcean","og_description":"Adding a subdomain with NGINX in DigitalOcean is simple. Make an \"A\" record for the subdomain. Then Make an index file and subdomain directory.","og_url":"https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/","og_site_name":"Server Management Services | Cloud Management | Skynats","article_publisher":"https:\/\/www.facebook.com\/skynats","article_published_time":"2022-09-07T11:17:11+00:00","article_modified_time":"2023-06-15T11:39:06+00:00","author":"Arjun N","twitter_card":"summary_large_image","twitter_creator":"@skynatstech","twitter_site":"@skynatstech","twitter_misc":{"Written by":"Arjun N","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/#article","isPartOf":{"@id":"https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/"},"author":{"name":"Arjun N","@id":"https:\/\/www.skynats.com\/blog\/#\/schema\/person\/2428d280a8b32a1fbd909b1411e32fb7"},"headline":"Add Subdomain With NGINX DigitalOcean","datePublished":"2022-09-07T11:17:11+00:00","dateModified":"2023-06-15T11:39:06+00:00","mainEntityOfPage":{"@id":"https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/"},"wordCount":326,"publisher":{"@id":"https:\/\/www.skynats.com\/blog\/#organization"},"articleSection":["Blog"],"inLanguage":"en-US"},{"@type":"WebPage","@id":"https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/","url":"https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/","name":"Add Subdomain With NGINX DigitalOcean | Skynats","isPartOf":{"@id":"https:\/\/www.skynats.com\/blog\/#website"},"datePublished":"2022-09-07T11:17:11+00:00","dateModified":"2023-06-15T11:39:06+00:00","description":"Adding a subdomain with NGINX in DigitalOcean is simple. Make an \"A\" record for the subdomain. Then Make an index file and subdomain directory.","breadcrumb":{"@id":"https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.skynats.com\/blog\/add-subdomain-with-nginx-digitalocean\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.skynats.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Add Subdomain With NGINX DigitalOcean"}]},{"@type":"WebSite","@id":"https:\/\/www.skynats.com\/blog\/#website","url":"https:\/\/www.skynats.com\/blog\/","name":"Server Management Services | Cloud Management | Skynats","description":"Server Management and Cloud Management","publisher":{"@id":"https:\/\/www.skynats.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.skynats.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.skynats.com\/blog\/#organization","name":"Skynats Technologies","url":"https:\/\/www.skynats.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.skynats.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/08\/Sknats-Logo-New-whole.png","contentUrl":"https:\/\/www.skynats.com\/blog\/wp-content\/uploads\/2021\/08\/Sknats-Logo-New-whole.png","width":989,"height":367,"caption":"Skynats Technologies"},"image":{"@id":"https:\/\/www.skynats.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/skynats","https:\/\/x.com\/skynatstech","https:\/\/www.instagram.com\/skynatstech\/","https:\/\/www.linkedin.com\/company\/skynats-technologies","https:\/\/www.youtube.com\/channel\/UCvTAjrFJ4_E2MJKwlDHomlg"]},{"@type":"Person","@id":"https:\/\/www.skynats.com\/blog\/#\/schema\/person\/2428d280a8b32a1fbd909b1411e32fb7","name":"Arjun N","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/e0f4d2489abeea1769beb944d2258c862259b62ff26853075066ca8ad37e3333?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/e0f4d2489abeea1769beb944d2258c862259b62ff26853075066ca8ad37e3333?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/e0f4d2489abeea1769beb944d2258c862259b62ff26853075066ca8ad37e3333?s=96&d=mm&r=g","caption":"Arjun N"}}]}},"_links":{"self":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/9628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/comments?post=9628"}],"version-history":[{"count":0,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/posts\/9628\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/media?parent=9628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/categories?post=9628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skynats.com\/blog\/wp-json\/wp\/v2\/tags?post=9628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}