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
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.
dokku ps:restart <app>
or dokku ps:rebuild <app>
first. –
Giusto 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.
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
).
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;
}
© 2022 - 2024 — McMap. All rights reserved.
/home/dokku/VHOST
. – Siccative/home/dokku/VHOST
file contains the "top-level" domain for your server. For instance, if you want an app name likeapp.dokku.me
, your file would containdokku.me
. – Raquel