Dokku - Add domain after setup
Asked Answered
C

5

23

I installed Dokku on my Digital Ocean droplet, but did it before setting my dns records, so Dokku was installed on IP. Now I changed my dns record, so site can be accessed through site.com. I can access my previously created Dokku containers through site.com:port, how can I change Dokku settings to access my app like this - appname.site.com

Coriss answered 14/2, 2014 at 17:35 Comment(3)
Try to explore this file: /home/dokku/VHOST.Siccative
Sure could use a way to reset the initial Dokku configuration to gain access to the setup GUI. Since I left domain configuration IP based, there is no VHOST file and I have no idea what it is supposed to contain.Giusto
The /home/dokku/VHOST file contains the "top-level" domain for your server. For instance, if you want an app name like app.dokku.me, your file would contain dokku.me.Raquel
S
19

Per https://github.com/progrium/dokku:

Set up a domain and a wildcard domain pointing to that host. Make sure /home/dokku/VHOST is set to this domain. By default it's set to whatever hostname the host has. This file is only created if the hostname can be resolved by dig (dig +short $(hostname -f)). Otherwise you have to create the file manually and set it to your preferred domain. If this file still is not present when you push your app, dokku will publish the app with a port number (i.e. http://example.com:49154 - note the missing subdomain).

To fix the issue, you will first need to update the /home/dokku/VHOST file, adding the domain name -- this will fix any newly generated deployments, but existing apps will need to be deleted from the /home/dokku directory by name (/home/dokku/foo, /home/dokku/bar, etc.) and redeployed for this change to take effect, since each Dokku application has a separate nginx.conf within those /home/dokku/ paths and those will need to be re-written.

Smut answered 11/3, 2014 at 6:19 Comment(2)
Just a note for anyone else, you may need to re-link containers (for instance if you are using a db plugin) if you delete and then add an app.Editing the /home/dokku/foo/nginx.conf properly would save that stepGrommet
Deleting the apps may be overkill, try dokku ps:restart <app> or dokku ps:rebuild <app> first.Giusto
S
8

It is indeed not necessary to destroy and recreate apps. First, dokku domains:report tells you if global VHOSTS are already enabled or not. If not, run

dokku domains:add-global yourdomain.tld
echo yourdomain.tld | sudo tee -a /home/dokku/VHOST
dokku domains:add myapp myapp.yourdomain.tld
dokku domains:enable myapp

The first of these adds yourdomain.tld to /home/dokku/HOSTNAME. It should also add it to /home/dokku/VHOST, but it doesn't. So that needs to be done manually. Then tell dokku what (sub)domain you want to access myapp on. The last command sets the NO_VHOST variable for myapp to false.

Shores answered 2/9, 2017 at 0:21 Comment(0)
E
5

To extend @shirkey answer: you don't need to re-create (destroy and create again) an app in order to apply those changes. You can manually create VHOST file inside /home/dokku/$APP/ directory (as dokku user) then remove NO_VHOST setting (dokku config:unset $app NO_VHOST) and change DOKKU_NGINX_PORT to 80 (dokku config:set $app DOKKU_NGINX_PORT=80) and restart the app (dokku ps:restart $app).

Eelgrass answered 27/1, 2016 at 15:52 Comment(0)
C
3

$ echo "example.com" > /home/dokku/VHOST

Charmaincharmaine answered 12/3, 2015 at 16:58 Comment(0)
P
0

If you still could add a subdomain. These are the points to check.

Example: add myapp.example.com.

1, DNS(e.g. Namecheap)

If you are using Cloudflare, Check if Custom DNS is set to Cloudflare.

2, CDN(e.g. Cloudflare)

Check if it has A record like this.

Type  |  Name   |   Content 
A     |  myapp  |  public ip address of Digital ocean server

3, VPS(e.g. Digital Ocean)

If you use Cloudflare you don’t have to set up Domain setting on Digital Ocean.

4, Dokku

  • Is port mapping set up properly? dokku proxy:report to check port 80 is mapped to the port of container.
  • Is the server running? Use curl from inside the server.

If you still could not locate the cause of the problem, check nginx config file like /home/dokku/appname/nginx.conf /etc/nginx/nginx.conf manually.

Example /home/dokku/appname/nginx.conf file

server {
  listen      [::]:80;
  listen      80;
  server_name myapp.example.com; 

location    / {
  proxy_pass  http://myapp-3030;
}

upstream myapp-3030 {

  server 172.17.0.4:3030;
}
Piggery answered 8/11, 2020 at 9:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.