Nginx and default_server?

I have some virtual hosts that work as I expect, but whenever I go directly to the server IP I’m redirected to one of the virtual host entries. I don’t want requests directly to the server IP to respond with anything. I learned that it’s default_server I want to use, but I’m not able to understand from the nginx derivation how to use it in my configuration.nix. Help?

You can use services.nginx.virtualHosts..default to set that.

As a word of warning, I tried this before and found it to work nothing like I expected, but I don’t remember the exact problem. It’s an nginx limitation though.

Edit: Hmm… It may have been related to SSL certificates with letsencrypt, so maybe not as general an issue as I thought.