Hi,
I’m currently developing Rails web app and I deploy it with Dokku to this droplet. I linked the droplet to my domain name. with the following settings:
A record @ >> droplet IP A record * >> droplet IP CNAME www >> mydomain.com.
I have deployed to subdomain myapp.mydomain.com however whenever I open random subdomain such as axz.mydomain.com and even the root domain (mydomain.com), it will be redirected to the app.
How to fix the issue? Thank you.
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Nginx will forward everything to the last server block config it can find. You need to have a default server set in nginx’s config and make sure it returns 404. See this StackOverflow answer on how to configure this.
By default, Dokku will route any received request with an unknown HOST header value to the lexicographically first site in the nginx config stack. If this is not the desired behavior, you may want to add the following configuration to the global nginx configuration.
Create the file at /etc/nginx/conf.d/00-default-vhost.conf:
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 410;
log_not_found off;
}
Make sure to reload nginx after creating this file by running service nginx reload.
This will catch all unknown HOST header values and return a 410 Gone response. You can replace the return 410; with return 444; which will cause nginx to not respond to requests that do not match known domains (connection refused).
The configuration file must be loaded before /etc/nginx/conf.d/dokku.conf, so it can not be arranged as a vhost in /etc/nginx/sites-enabled that is only processed afterwards.
Alternatively, you may push an app to your Dokku host with a name like “00-default”. As long as it lists first in ls /home/dokku/*/nginx.conf | head, it will be used as the default nginx vhost.
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.