/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 restartEdit hosts file
$ nano /etc/hostsAppend to the end of the file
127.0.0.1 localhost
# ....
127.0.0.1 example.com www.example.com
example.com www.example.comthe domains that will be map to IP Address.127.0.0.1or localhost, the domain names that matches the query will be mapped to this address, this case areexample.comandwww.example.comdomains. External IP Adresses are also valid, of course 😂.
$ curl http://example.com
$ curl http://www.example.com