Dokku isn’t clear how to host a server when you don’t have a domain you want to use. If you don’t enable their vhost by default then the external port of your app CHANGES EVERY DEPLOY. They only describe in detail their http://subdomain.domain.com deploy. Here I show you how to use the http://ipaddress:port deploy in a consistent manner.
Edit: They are now fixing the issue!!! https://github.com/progrium/dokku/issues/1123#issuecomment-141173545
Why was this so hard to figure out?
- When I asked how to do it on Github, I didn’t get an answer https://github.com/progrium/dokku/issues/1123#issuecomment-140610139
- When I asked how to “keep a consistent port when not using vhost” in their IRC channel #dokku I got the response “put a vhost on it”. Not helpful…
- When you don’t config their vhost, nginx doesn’t run. That means I spent about 1 hour configuring nginx.conf not realizing it wasn’t even enabled.
- Nginx is only enabled when NO_VHOST is set correct, VHOST and HOSTNAME files are set with the domain. Items mentioned in the documentation here http://progrium.viewdocs.io/dokku/nginx/ under “container network interface binding”.
- The docs don’t make mention of this possible configuration. I guess everyone always has a domain they want to use or doesn’t care when the external port changes.
How to configure this?
- If you already have a deployed app, delete it
dokku delete myApp
- add a VHOST file in your ~dokku (not to be confused with ~/dokku which is nothing)
- add a fake domain to your HOSTNAME (fakedomain.com) file in your ~dokku directory
- deploy your app
git remote add dokku dokku@ipaddress:myApp
git push dokku master
- (optional) restart and relink your mongodb if applicable
dokku mongodb:link myApp
dokku ps:restart myApp
- (optional) set extra env variables on your app
dokku config:set myApp NODE_ENV=dev
- change the ~dokku/myApp/nginx.conf file to
In my example nginx.conf file I will be able to always connect to the server by typing in http://myipaddress:80. Even between deployments.