I deployed an app to my Digital Ocean Dokku instance, and set it up with a domain such that https://example.com
(using letsencrypt dokku plugin) points to my originalApp
. I recently tried to deploy a second app on my Dokku instance thinking I would be able to access it with http://newApp.example.com
, and eventually use new-example.com
to access it.
However, I cannot access my new app.
dokku domains:report
yields:
=====> newApp domains information
Domains app enabled: true
Domains app vhosts: new-example.com newApp.example.com
Domains global enabled: true
Domains global vhosts: example.com
=====> originalApp domains information
Domains app enabled: true
Domains app vhosts: example.com
Domains global enabled: true
Domains global vhosts: example.com
The final goal is to have two separate domains pointing to their respective apps. (Is this even possible?) But at the moment, I can't even get the subdomains to work.
I confirmed the app is running by dokku logs newApp
In the Digital Ocean > Networking section, my newDomain.com
has the Digital Ocean NS records as well as the A
record to my Droplet's IP.
Could this have something to do with my nginx
setup or letsencrypt
?
Its possible, I have done it several times with DigitalOcean droplets and you will have your mini-Heroku at last. It's a kind of tricky to get it working but I will try to explain my steps to replicate it.
First of all you need to deploy your DO droplet with Dokku to get started. Remember to select the option "Use virtualhost naming for apps" during the installation!
In your DNS you will have to configure an A
record to access your server with a domain that will hold your different apps (subdomains).
Creating a "base" A
record for the Dokku instance can make it easier to access, but is not required (only affects instance, not app subdomains!).
# Enable app subdomain routing
A *.apps.example.com <public IP address>
# Optional subdomain for Dokku instance
A apps.example.com <public IP address>
Now you need to deploy your two apps on the server to get started with the configuration. Create the apps and deploy them (Use google if you need help to deploy it). Finally, you should see this in your server:
root@server-dokku-apps:~# dokku apps:list
=====> My Apps
acme-website
bubba-gump-website
Now you will need to configure the domain for each Dokku app.
root@server-dokku-apps:~# dokku domains:add acme-website www.acmewebsite.com
-----> Added www.acmewebsite.com to acme-website
-----> Configuring www.acmewebsite.com...(using built-in template)
-----> Configuring acme-website.apps.example.com...(using built-in template)
-----> Configuring www.acmewebsite.com...(using built-in template)
-----> Creating https nginx.conf
-----> Running nginx-pre-reload
Reloading nginx
root@server-dokku-apps:~# dokku domains:add bubba-gump-website www.bubbagump.com
-----> Added www.bubbagump.com to bubba-gump-website
-----> Configuring www.bubbagump.com...(using built-in template)
-----> Configuring bubba-gump-website.apps.example.com...(using built-in template)
-----> Configuring www.bubbagump.com...(using built-in template)
-----> Creating https nginx.conf
-----> Running nginx-pre-reload
Reloading nginx
Check that you can access the apps using the default Dokku domains (only http so far):
http://acme-website.apps.example.com
http://bubba-gump-website.apps.example.com
If everything is working as expected, configure each domain to point to the right app with some CNAME records.
# In your www.acmewebsite.com DNS records
CNAME www.acmewebsite.com www.acmewebsite.com.apps.example.com
# In your www.bubbagump.com DNS records
CNAME www.bubbagump.com www.bubbagump.com.apps.example.com
The final step is to configure letsencrypt
on each app. To let letssencrypt
provide a new certificate, your new domain (ex. www.acmewebsite.com) need to be accessible. This is why we first need to place the DNS CNAME
! Remember to install dokku-letsencrypt on your server.
# First for acme website
root@server-dokku-apps:~# dokku letsencrypt acme-website
# Finally for buba website
root@server-dokku-apps:~# dokku letsencrypt bubba-gump-website
After all this mess you should have two shiny apps running in their own domains with HTTPS enabled.
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With