I finally managed to deploy my Rails app to a DigitalOcean server. In the end of the deployment log, there were these two lines:
...
-----> Shutting down old containers in 60 seconds
=====> Application deployed:
http://myapp-prod.packer-6481b5fa-xxxx-yyyy-zzzz-a2621ac2dcee:3000
http://test:3000
The first URL, http://myapp-prod.packer-6481b5fa-xxxx-yyyy-zzzz-a2621ac2dcee:3000
, doesn’t work – returns This site can’t be reached. The second one, http://test:3000
, obviously doesn’t work either.
When I try to put the IP address of my server (that is also shown in /home/dokku/VHOST
), it returns This site can’t be reached.
On the server is the dokku directory, /home/dokku/myapp-prod
, and there’s this file nginx.conf
:
server {
listen [::]:3000;
listen 3000;
server_name myapp-prod.packer-6481b5fa-f32f-c6ab-b44d-a2621ac2dcee test;
access_log /var/log/nginx/myapp-prod-access.log;
error_log /var/log/nginx/myapp-prod-error.log;
location / {
gzip on;
gzip_min_length 1100;
gzip_buffers 4 32k;
gzip_types text/css text/javascript text/xml text/plain text/x-component application/javascript application/x-javascript application/json application/xml application/rss+xml font/truetype application/x-font-ttf font/opentype application/vnd.ms-fontobject image/svg+xml;
gzip_vary on;
gzip_comp_level 6;
proxy_pass http://myapp-prod-3000;
proxy_http_version 1.1;
proxy_read_timeout 60s;
proxy_buffer_size 4096;
proxy_buffering on;
proxy_buffers 8 4096;
proxy_busy_buffers_size 8192;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $http_connection;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Port $server_port;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Request-Start $msec;
}
error_page 400 401 402 403 405 406 407 408 409 410 411 412 413 414 415 416 417 418 420 422 423 424 426 428 429 431 444 449 450 451 /400-error.html;
location /400-error.html {
root /var/lib/dokku/data/nginx-vhosts/dokku-errors;
internal;
}
error_page 404 /404-error.html;
location /404-error.html {
root /var/lib/dokku/data/nginx-vhosts/dokku-errors;
internal;
}
error_page 500 501 502 503 504 505 506 507 508 509 510 511 /500-error.html;
location /500-error.html {
root /var/lib/dokku/data/nginx-vhosts/dokku-errors;
internal;
}
include /home/dokku/myapp-prod/nginx.conf.d/*.conf;
}
upstream myapp-prod-3000 {
server 172.17.0.3:3000;
}
EDIT: Running dokku network:list
returns
=====> Networks
bridge
host
none
This might sound like a silly question, but how do I "activate"/make accessible the deployed app via dokku?
2
Answers
What I had to do was to ssh into the server and enter
ufw status 3000/tcp
. Then after entering http://IP:3000 the website shows up.In this case, the app has "invalid" domains associated with it, where "invalid" means they aren’t routable via DNS. Dokku does not perform a DNS lookup as there are cases where something might not be addressable via public DNS but routable due to some other networking "magic" (such as via mDNS or some potentially some intermediary proxy).
After setting the ip address of your server to a domain on your DNS provider, you can assign the domain to the app via:
Additionally, your app appears to be a
Dockerfile
based app. When Dokku builds aDockerfile
app, it will respect anyEXPOSE
directives and use those for public proxying. For example, if you have the following in yourDockerfile
:And a domain of
example.com
associated with the app, your app would be accessible athttp://example.com:3000
. The port would also need to be open in any firewalls you have in place (iptables/ufw/hosting provider firewalls or security groups).Due to how nginx works, accessing
http://example.com:80
would route to the first app listening on port 80 as it defaults to the first server block in lexicographical order. If there is no app listening on port 80, nginx will just not service the request.To fix the port mapping, you can run the
ports:set
command. This will override the detected port mapping and be in use for the lifetime of your app.