Search code examples
nginxdokku

Dokku: Prevent rogue domain from getting served by nginx


I have a simple Rails application running in a Dokku instance. I have my own domain pointing to it, but I also found there is a rogue domain pointing to my server. The rogue domain gets also served by my Dokku based application.

Guestion: How can I prevent Dokku from serving other than the domain I have specified?

I guess I could have something like server { return 404 } in nginx.conf file, but I'm not sure how Dokku plays with these nginx configurations..


Solution

  • You can set server_name for you domain only:

    server {
       server_name your.domain;
       ...
    }
    

    and yes, you can wrap rogue domain with server {} too

    server {
       server_name rogue.domain;
       return 404;
    }
    

    place it into http {} section (nginx.conf OK)

    Dokku: App specific Nginx configuration can be set for example with dokku-nginx-alt plugin. There is also conversation related to dokku and nginx.conf in this github issue.