Reputation: 105193
I have Dokku installed on a server, with multiple sites/domains deployed to it. When one of my sites goes down, all HTTP requests to it get redirected (for some reason) to another site. This is confusing. I'm expecting Dokku to show some error page in this case. Is it the default behavior or I did something wrong?
PS. This is the problem: https://github.com/dokku/dokku/issues/2602
Upvotes: 9
Views: 861
Reputation: 26473
This is not directly a Dokku issue, but a configuration issue with nginx.
If you don't have a default_server
defined then nginx will fallback to the first server block in the configuration. This seems random, but is likely the Dokku app with the lexicographically first name.
To prevent this behavior add the following default server block manually:
# /etc/nginx/conf.d/default-site.conf
# Set default_server to drop/reject connections both http/https
server {
listen 80 default_server;
listen [::]:80 default_server;
listen 443 default_server;
listen [::]:443 default_server;
access_log off;
ssl_reject_handshake on; # Close https connection without response
return 444; # Close http connection without response
}
Upvotes: 0
Reputation: 3728
How about adding a custom error page based on the error code by editing vhost file:
server{
server_name www.foo.com;
root /srv/www/foo/public_html;
expires 1M;
access_log /srv/www/foo/logs/access.log;
error_log /srv/www/foo/logs/error.log;
error_page 404 /404.html;
location / {
index index.html;
rewrite ^/(.*)/$ /$1 permanent;
try_files "${uri}.html" $uri $uri/ =404;
}
location = /404.html {
internal;
}
}
Your server error might be caught from codes 404 or 500
Upvotes: 0