/etc/nginx/sites-enabled/example.com.conf
server {
listen 80;
server_name example.com www.example.com;
location / {
add_header Content-Type text/plain;
return 200 'Hello World!';
}
}
$ nginx -t && systemctl restart nginx # service nginx restart
Edit hosts file
$ nano /etc/hosts
Append to the end of the file
127.0.0.1 localhost
# ....
127.0.0.1 example.com www.example.com
example.com www.example.com
the domains that will be map to IP Address.127.0.0.1
or localhost, the domain names that matches the query will be mapped to this address, this case areexample.com
andwww.example.com
domains. External IP Adresses are also valid, of course 😂.
$ curl http://example.com
$ curl http://www.example.com