Discourse stopped working with 404 errors

Consider this problem sorted.

Apparently the control panel I use to manage my server has a bunch of different nginx setups, and I had somehow managed to switching it from a default proxy nginx configuration to a caching nginx configuration.

The minute I switched it back to a default proxy config, everything started working again. Only 3 days wasted trying to sort this and in the end it was completely unrelated to the server{} directives of nginx.