Redirecting Uppercase URLs to Lowercase in a Dokku Powered App
By default, Dokku Nginx's config doesn't redirect uppercase urls to their lowercase version.
SEO experts say it might not be good having the same page served by two distinct urls like: youapp.com/foo
and youapp.com/FOO
. Let's see how we can do that.
Override Nginx configuration
We need to override Nginx default configuration so we can change it.
Check the version of Dokku running on your server:
Download Nginx default config on https://raw.githubusercontent.com/dokku/dokku/v0.21.4/plugins/nginx-vhosts/templates/nginx.conf.sigil
(replace 0.21.4
by your version number) and put its content in a file nginx.conf.sigil
in the root of your app.
Add the following location
directive inside the corresponding ssl server
(before the main location /
), commit and deploy:
If you see the error below when deploying, it's because you don't have the lua module installed.
You can confirm by checking that 50-mod-http-lua.conf
is missing between enabled modules:
Install nginx-extras
Let's install nginx-extras
to have the lua module:
Restart Nginx:
Great, you can check everything is ok by testing the Nginx config now:
If you list the enabled modules again, there we have it:
Finally, it's always good making a request to confirm we are redirecting with 301 Moved Permanently
:
That's all.