Search code examples
apachetomcatmod-proxyconfluenceajp

Avoid 302 Redirects through Apache


Hello I have a confluence installation running on tomcat. In front of tomcat I have an apache server.

When I go to my page a 302 to /homepage.action is done and afterwards a redirect to the start space set in confluence and then a third redirect to actual start page of this page.

This is annoying and I don't know how the google bot is affected by it.

Thus I have two questions:

  1. How is the google bot affected by all this redirects?
  2. How can I avoid these redirects with apache?

I tried to make a proxy directive directly to my landing page.

<LocationMatch ^/$>
    ProxyPass ajp://myurl:8009/mysite
    ....
</LocationMatch>
<LocationMatch /*>
    ProxyPass ajp://myurl:8009/
    ....
</LocationMatch>

But this does not work. Either I get a 404 or I get to every request the same response.

Currently I got this configuration working:

<LocationMatch />
    ProxyPass ajp://myurl:8009/
    ....
</LocationMatch>

But this leads to a not so cool URL at the starting page.

Kind regards

Christian


Solution

  • Atlassian has documented this use case.

    UPDATE 4/20/2011

    Well, I tried mod_proxy with Confluence and, like you, didn't like the results. I found using mod_jk to be simpler and cleaner (which I think is your objective here with the friendly URLs).

    Again, Atlassian has documented how to use mod_jk. Here are my configs:

    [confluence-install]/conf/server.xml

    <Connector port="8016"
                  enableLookups="false" protocol="AJP/1.3" minSpareThreads="5" maxThreads="256" URIEncoding="UTF-8" />
    

    [/etc/apache2/workers.properties]

    worker.list=confluence
    worker.confluence.host=localhost
    worker.confluence.port=8016
    worker.confluence.type=ajp13
    

    [/etc/apache2/httpd.conf]

    NameVirtualHost 1.2.3.4:80
    <VirtualHost 1.2.3.4:80>
            ServerAdmin webmaster@localhost
            ServerName confluence.domain.com
    
            # Possible values include: debug, info, notice, warn, error, crit, alert, emerg.
            LogLevel warn
    
            ErrorLog /var/log/apache2/confluence-error.log
            CustomLog /var/log/apache2/confluence-access.log combined
    
            JkMount / confluence
            JkMount /* confluence
    
            JkLogLevel warn
            JkLogFile /var/log/apache2/confluence_jk.log
    
    </VirtualHost>
    

    Hopefully, switching to mod_jk is an option for you. I hope this helps resolve your question.