Force Jira redirection to single domain

SamK July 19, 2011

Hi,

My Jira installation is available using different adresses: IP address and domain (with and without www).

I want Jira accessible only with www; others accesses would redirect to the main access.

In fact, I would need some equivalent to Apache's RewriteRule but I don't know Tomcat good enough to figure out by myself.

5 answers

1 accepted

0 votes
Answer accepted
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 19, 2011

Agree with Nic, url rewriting is probably best done in apache, but I don't see why you can't use the tuckey filter.

Modify web-inf/urlrewrite.xml - docs here: http://urlrewritefilter.googlecode.com/svn/trunk/src/doc/manual/3.2/index.html

This example is more or less what you want, just change the host instead of the scheme: http://stackoverflow.com/questions/3385034/urlrewritefilter-direct-to-https/3385100#3385100</p<>>

2 votes
Jim Birch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 20, 2011

Add the following filter rule to atlassian-jira\WEB-INF\urlrewrite.xml.

This should be the top rule, processed before any other.

    <!-- added to force url to jira.abcdef.local, avoids url issues jsb 20101130 -->
    <rule>
    <name>Domain Name Check</name>
    <condition name="host" operator="notequal">jira.abcdef.local</condition>
    <from>^(.*)$</from>
    <to type="redirect">http://jira.abcdef.local$1</to>
    </rule>
changming su November 5, 2014

Hi, I add url rewrite successfully for Jira and Stash. But fail to implement on Bamboo and Confluence. Any idea why? It just doesn't seem to redirect. Thanks!

David Doleman May 25, 2015

were you able to get Confluence and Bamboo going with the url rewrite?

Aram Ghanimian June 7, 2017

@changming su

I assume you are in the same environment as I, and that you are running your Atlassian instances in windows as a service.

In your Confluence isntance try this:

<confluence install home>\confluence\WEB-INF\web.xml

Make sure that your filter mapping is applied that is in the tuckey.org/urlrewrite manual;

<filter-mapping>
    <filter-name>UrlRewriteFilter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>FORWARD</dispatcher>
</filter-mapping>

This was missing in my web.xml. I applied it just under the first <filter-mapping> element for URLRewriteFilter.

 The solution that Jim Burch provided worked for me and my resident Web guru verified the syntax. And since it worked for your JIRA and Stash instances, I figure that had to be missing in your confluence instance. Please let us know if it works.

Roger Mejia March 19, 2018

@Jim Birch

Jim I came across your URLRewrite filter post for Jira I tried to configure it and I can't seem to get it to work correctly were there any other lines you added to the URLRewrite.xml file and what changes did you add to the Web.xlm file if any. We are currently using it for Confluence just fine with no issues. Not sure if for Jira it's a little different.

Jim Birch
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 19, 2018

We aren't using this in Jira now.  This was a while back and I can't remember why for sure, but I think it might have been because I couldn't get it running either after an upgrade or when we started running websites through a web management device.  I didn't really follow it up.

0 votes
SamK July 19, 2011

Are you telling me that no mod_rewrite equivalent exists for Tomcat? I can't belive it.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
July 19, 2011

I've never seen rewriting done in Tomcat, everyone who needs rewriting usually has more complex requirements than a single rewrite rule, and uses Apache to do it.

0 votes
Martin Bayreuther July 19, 2011

Why not use a redirect on the Apache side?

Typically you would have Apache running anyway, so you could use the virtual server there plus a redirect.

Best regards

Maba

SamK July 19, 2011

Thank's for your answer, however I don't want to do that, I want to keep it simple. (i.e. no additionnal layers and no reverse proxy).

SamK July 19, 2011

Using additional services such as Apache is a little bit too heavy for the purpose. Using Tomcat would be prefered.

Suggest an answer

Log in or Sign up to answer