Skip to content Skip to sidebar Skip to footer

Set Up Your Own Domain By Configuring Basic Server Block In NGINX

Now i will documenting nginx's basic server block that works for testing purposes. This intend to make computer working and able to serve multiple web address in same machine.

Based on, Server Blocks are a feature of the Nginx web server that allows you to host multiple websites on one server. As opposed to setting up and configuring a server for each domain, hosting a number of websites on a single machine saves both time and money.

Before begin, there are two places to save a server block. There are sites-available and sites-enabled. Sites-available are place that used to only keep the configuration of server block, and sites-enabled are place to keep and run every server block that saved in here. To me, sites-available are used to only save a configuration file of server block.

So, if you willing to create a server block to host a website, you must make and save it to sites-enabled to make it able to run. The location are in /etc/nginx/sites-enabled/

For educational purpose, i'm gonna make a server block that named "website".  The steps that i supposed to do is written as below :
  1. Type in "cd /etc/nginx/sites-enabled/" without quote
  2. Then, type in "nano website" without quote
  3. After that, i put some configuration as picture below. A hashtag (#) symbol are used as comment and will not gonna executed so it all safe for you to not write everything in # since it's using Bahasa or you can make a comment for it yourself. As example, here i use as website domain.

  4. Save by pressing ctrl + x + y and then press enter
  5. Restart nginx to make your server block run by typing "service nginx restart" without quote
  6. Now try to access your domain you configure. When the browser says "Welcome to Nginx" then it's working properly.