Playing around with technology

Tag archive: nginx

Categories: Technology

whoami with nginx

Out of the cookbook of services that you need from time to time there is another service which I decided to host myself: whoami. While “whoami” is a rather broadly used term with different meanings in this particular case it means: “what is my external IP address?”.

One way to find out is to use a service that returns your external IP address as a text string. Luckily this can be easily implemented in nginx. The configuration is rather simple:

server {
    listen          [::]:443 ssl http2;
    listen          443 ssl http2;
    server_name     whoami.mydomain.tld;
    default_type    text/plain;
    return          200 "$remote_addr\n";

    ssl_certificate […]/fullchain.pem;
    ssl_certificate_key […]/privkey.pem;

The most important lines are 5 and 6. These tell nginx to return1 a text string with the remote address (external IP) of the visitor. The \n after $remote_addr adds a end-of-line character to prevent issues with programs not recognizing the end of file otherwise. All other lines are commonly used nginx settings in order to use SSL, http2 etc. Further information on these commands is available from the nginx documentation.

So how do I get my IP address once everything is running? For instance you could use curl to get your IPv4 (using the -4 flag) or IPv6 (using the -6 flag) address:

curl -6 https://whoami.mydomain.tld

  1. We make use of the nginx return function which is shipped with the http_rewrite_module module. As long as you have not explicitly disabled building the module it should be available in your installation. ↩︎

Categories: Projects


For obvious reasons it is sometimes good to build programs from source. I frequently do that with nginx. To ease this process I’ve written a small shell script to facilitate this job.

Categories: Diary

Costs to run this blog

I happily noticed that the number of (self-hosted) blogs I came across has increased recently. The latter ones feature some posts where people did a break down of the monthly costs for their blog. Great idea, let’s see what this means for sciolism.

Hosting & Domain

This blog runs on a small VPS hosted by DigitalOcean. The monthly costs are about $6. The domain is about 9€ per year with DNS being managed via DigitalOcean. The certificates for encryption are provided by Let’s Encrypt and are free of charge.


As every blog or website this blog heavily relies on software. First of all there is the CMS or in this case the static site generator hugo which is free of charge. The webserver on the VPS is a nginx instance - free of charge, too. Other software like a FTP clients, text or graphic editors can hardly be attributed since they are used for multiple purposes.

Wrap up

In total the monthly costs are about 6-7€ which is absolutely ok and underlines that self-hosting is affordable. I think it is important to point out that the costs would be much higher with all components being charged, so it is a good opportunity for a big shout-out to the many (open-source) projects that help to run this blog.