Dokku - Add domain after setup

主宰稳场 提交于 2019-12-04 08:18:06

问题


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


回答1:


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.




回答2:


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.




回答3:


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).




回答4:


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



来源:https://stackoverflow.com/questions/21785901/dokku-add-domain-after-setup

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!