Now that we have configured the DNS settings for our subdomain, we can update our NGINX configuration files to bear the name of our domain.
In the /etc/nginx/sites-available and /etc/nginx/sites-enabled directories, update the names of the files to the corresponding FQDN (without the trailing period):
hobnob@hobnob:$ cd /etc/nginx/sites-available/
hobnob@hobnob:$ sudo mv api api.hobnob.social
hobnob@hobnob:$ cd /etc/nginx/sites-enabled/
hobnob@hobnob:$ sudo rm api
hobnob@hobnob:$ sudo ln -s /etc/nginx/sites-available/api.hobnob.social \
/etc/nginx/sites-enabled/
Lastly, update the configuration file to include a server_name directive. For example, the api.hobnob.social server block now looks like this:
server {
listen 80 default_server;
server_name api.hobnob.social
location / {
proxy_pass http://localhost:8080;
}
}
Now, reload our NGINX configuration to ensure that the changes take effect:
$ sudo systemctl reload nginx.service
Now, try sending a request to api.hobnob.social, and you should see the API server respond correctly!