Hostname redirects with Confluence (standalone)
Asked by MICHAEL O'Neill:

Greetings!

So here's a tricky one. We're using the Confluence 3.5.13 Standalone (comes with Tomcat bundled) and we now have the need to implement some redirect functionality.

Currently we have three hostname entries in our dns pointing to one confluence server:

1. <http://fred.example.com>
2. <http://wilma.example.com>
3. <http://barney.example.com>

While that works fine, we'd like to have confluence actually redirect any traffic pointing to either <http://fred.example.com> or <http://wilma.example.com> to <http://barney.example.com>.

As far as I understand it, redirects like this are usually handled in either the application or web server layer (and not in the DNS layer).

Some examples to clarify. We'd like to setup redirects so that:
\<th\>Traffic To\</th\>\<th\>Is Redirected To\</th\>

|-------------------------------------------|----------------------------------------------|
| <http://fred.example.com>                 | <http://barney.example.com>                  |
| http://wilma.example.com/dashboard.action | <http://barney.example.com/dashboard.action> |
| <http://fred.example.com/anything>        | <http://barney.example.com/anything>         |

Basically, we want to start training our users to use the "example3" hostname by having all traffic that points to the server redirected to it.

Any thoughts?


Answers:
author: Nic Brough -Adaptavist-
body: This isn't something that I'd suggest doing in Tomcat, and certainly not in Confluence (it really doesn't care where you've come from). I'd reach for Apache - many people run Atlassian products behind Apache for all sorts of reasons.

The reason I'd use it here is simple - it's a doddle to do rewrites with Apache - see <http://confluence.atlassian.com/display/DOC/Using+mod_rewrite+to+Modify+Confluence+URLs>

Note - these are reWRITES, not reDIRECTS. Redirects will work, but the user will see what they typed in change, and there can be visual indicators that one page starts to render and then it jumps to another. The rewrite will prevent that, as it's a single rendering. The only problem you might run into is "hey, I typed in [fred.example.com](http://fred.example.com), why does confluence send me email pointing at barney?"

comments: author: MICHAEL O'Neill
body: Hmm... Thanks Nic!
>
> Redirects will work, but the user will see what they typed in change, and there can be visual indicators that one page starts to render and then it jumps to another. The rewrite will prevent that, as it's a single rendering. The only problem you might run into is "hey, I typed in [fred.example.com](http://fred.example.com), why does confluence send me email pointing at barney?"

I think we kind of want that. Right now people can browse the same content using any of three hostnames in the URL: fred, wilma or barney. This leads to pandemonium, as people are sending links out using all three hostnames, etc. We want to explicitly redirect them to "barney" if they use any of the others ("fred" or "wilma"). Seing the url change on them is OK with us, as it will reinforce the url people should be using.

If the redirect was taken care of in tomcat before a page started to render, users should see no partial loads \& redraws. If the application were taking care of a redirect, then I could see that being an issue...but ideally the redirect would happen in tomcat/the application container before the application stack (confluence) even started to do anything.

With that said, if using mod_rewrite would provide the same experience, I'm game for that. One complication, however: we aren't running apache in front of tomcat and it doesn't seem likely that we'd be able to successfully get the server maintainers to go there. That leaves us with tomcat options...


author: MICHAEL O'Neill
body: \<deleted\>


Tags: cname

hostname

redirect

tomcat