dokku / dokku-redirect

A plugin for dokku that gives the ability to set simple redirects for an application
MIT License
107 stars 9 forks source link

Possibility to handle URL redirect #2

Closed Kikobeats closed 8 years ago

Kikobeats commented 8 years ago

is it possible?

Maybe make possible configure something like:

www.domain.com/* → domain.com/$1
josegonzalez commented 8 years ago

Did you try it?

Kikobeats commented 8 years ago
nginx: [warn] server name "www.zombeats.es/*" has suspicious symbols in /home/dokku/zombeatsblog/nginx.conf:89
nginx: [warn] server name "www.zombeats.es/*" has suspicious symbols in /home/dokku/zombeatsblog/nginx.conf:95
nginx: [emerg] invalid server name or wildcard "www.zombeats.es/*" on [::]:80
nginx: configuration file /etc/nginx/nginx.conf test failed

maybe is possible to setup but I don't know the correct nginx template for to this.

Kikobeats commented 8 years ago

And now mi redirects is buggy

dokku redirect:unset zombeatsblog www.zombeats.es/*
-----> Unsetting redirect for zombeatsblog...
sed: -e expression #1, char 19: unknown command: `*'

xD

josegonzalez commented 8 years ago

You'll want to remove it from your /home/dokku/APP/REDIRECTS file manually.

You probably wanted:

dokku redirect:set my-app www.zombeats.es zombeats.es
Kikobeats commented 8 years ago

I'm checkin this: http://stackoverflow.com/a/7958540

for do a ww to non-www redirect maybe we can edit the template for add this special case:

server {
        listen 80;
        server_name www.domain.com;
        # $scheme will get the http protocol
        # and 301 is best practice for tablet, phone, desktop and seo
        return 301 $scheme://domain.com$request_uri;
}
josegonzalez commented 8 years ago

Did you try my suggestion?

Kikobeats commented 8 years ago

yay better now, thanks!

Kikobeats commented 8 years ago

@josegonzalez finally don't possible make a total URL redirect, that was my real intention, sorry. Check how to www non redirect to non-www.

I'm sure that If I edit the nginx template manually probably yes, but it's created in each build, right? Can I do something for fix it?

josegonzalez commented 8 years ago

I don't understand how what your suggestion is different from what we are currently doing?

Kikobeats commented 8 years ago

As you say in the documentation:

This plugin only redirects one domain to another and does not handle complete URLs. 

so, this works:

$ http-traceroute https://www.zombeats.es
[200] HEAD https://zombeats.es (284 ms)
Trace finished in 285 ms using 0 hop

but this doesn't work:

$ http-traceroute https://www.zombeats.es/hola-2016-anunciamos-zombeats-blog-y-mas-sorpresas/
[404] HEAD https://zombeats.es/hola-2016-anunciamos-zombeats-blog-y-mas-sorpresas (270 ms)
Trace finished in 271 ms using 0 hop

so, based in the nginx template, is possible to handle URL Redirect?

josegonzalez commented 8 years ago

It already does. Are you sure that content exists on your app?

Kikobeats commented 8 years ago

Hmmm looks that something is bad in my DNS settings.

My domain for the dokku installation is sailorjs.org

when I enter in the subdomain for the zombeats app, https://zombeatsblog.sailorjs.org/ show another app endpoint.

Any idea about that?

josegonzalez commented 8 years ago

That domain you are now referring to is zombeatsblog, not zombeats. Are you sure you configured the right app?

Kikobeats commented 8 years ago

Yes, sorry. The point that I'm trying to fix is that something is wrong in my configuration.

I have two apps: zombeatsblog and kikoblog.

But looks that the subdomains url points to the same app! https://kikoblog.sailorjs.org https://zombeatsblog.sailorjs.org/

but domains associated with the apps looks that works fine: https://kikobeats.com https://zombeats.es

but not the www redirect! https://www.zombeats.es :-(

Any idea how to fix it?

josegonzalez commented 8 years ago

Can you list the domains you've specified for each application? Both with dokku-redirect and the domains plugin.

Kikobeats commented 8 years ago
root@ubuntu-1gb-lon1-01:/var/log/nginx# dokku domains kikoblog
=====> kikoblog Domain Names
kikobeats.com
www.kikobeats.com
kikoblog.sailorjs.org

root@ubuntu-1gb-lon1-01:/var/log/nginx# dokku domains zombeatsblog
=====> zombeatsblog Domain Names
zombeatsblog.sailorjs.org
zombeats.es
www.zombeats.es

root@ubuntu-1gb-lon1-01:/var/log/nginx# dokku redirect zombeatsblog
SOURCE           DESTINATION
www.zombeats.es  zombeats.es

root@ubuntu-1gb-lon1-01:/var/log/nginx# dokku redirect kikoblog
 !     There are no redirects for kikoblog
josegonzalez commented 8 years ago

The redirect looks like it works fine.

Are you trying to have duplicate content with those sailorjs domains?