tracd behind an apache2 proxy
March 2010
Sun Mon Tue Wed Thu Fri Sat
  1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30 31      
About
This site is an effort to share some of the base knowledge I have gathered through all this years working with Linux, FreeBSD, OpenBSD, Python or Zope, among others. So, take a look around and I hope you will find the contents useful.
Recent Entries
Recent Comments

collective.plonetruegallery 0.8.2b3
2010-03-10 plone.org releases

Press Room 3.3
2010-03-10 plone.org releases

Products.Scrawl 1.3.2
2010-03-10 plone.org releases

Self-motivator: Programming You might not know him. You should....
2010-03-09 Ramble on

La Copy & Paste Web
2010-03-09 blackshell

Branco
2010-03-09 emereci

Melodía
2010-03-09 emereci

Palabras Contadas
2010-03-09 emereci

Speed test between django_mongokit and postgresql_psycopg2
2010-03-09 peterbe.com

In July
2010-03-09 Ramble on

Dark Yellow Morning Sky
2010-03-09 betabug

Vende enlaces con backlinks.com
2010-03-09 userlinux.net

OpenSSH 5.4 released
2010-03-09 OpenBSD Journal (undeadly.org)

Mercurial en Fedora Core 4 y CentOS 5
2010-03-08 userlinux.net

How and why to use django-mongokit (aka. Django to MongoDB)
2010-03-08 peterbe.com

"As Spain holds the rotating Presidency of the EU Council, it is currently defining a European..."
2010-03-07 Ramble on

Planting Trees
2010-03-07 betabug

Returning committer: Niels Heinen (ports)
2010-03-07 FreeBSD latest news

pjsua: The Geek Out SIP Client
2010-03-06 betabug

Ubuntu Cola or Ubuntu Linux
2010-03-06 peterbe.com

DbWrench Database Design & Synchronization v1.6.3
2010-03-05 PostgreSQL latest news

High performance Grails with memcached
2010-03-04 Oliver's place (django)

Notificador para Spotify en Linux sobre Wine
2010-03-04 vaites (dmnet)

FreeBSD 7.3-RC2 Available
2010-03-04 FreeBSD latest news

Global hotkeys para Spotify en Linux sobre Wine
2010-03-03 vaites (dmnet)

"[…] when researchers extract a single food from a diet of proven value, it usually fails to..."
2010-03-03 Saâd Kadhi / The Web self()

New committer: Neel Natu (src)
2010-03-03 FreeBSD latest news

DynDNS, ddclient y mundo-r
2010-03-02 userlinux.net

This Month in Plone - March 2010
2010-03-02 plone.org news

Announcing the Plone logo usage guidelines & policy
2010-03-02 plone.org news

Recent Trackbacks
Categories
OpenBSD (8 items)
BSD (0 items)
FreeBSD (11 items)
Linux (1 items)
Security (3 items)
Python (18 items)
Zope (12 items)
Daily (104 items)
e-shell (7 items)
Hacks (7 items)
PostgreSQL (3 items)
OSX (7 items)
Nintendo DS (0 items)
enlightenment (0 items)
Apache (3 items)
Nintendo Wii (0 items)
Django (23 items)
Music (9 items)
Plone (7 items)
Archives

Syndicate this site (XML)

RSS/RDF 0.91

05 febrero
2010

tracd behind an apache2 proxy

wrong redirect after adding a ticket

I found this weird behaviour with tracd and an apache proxy today, while setting up some public trac access for one of our projects.

This is the setup (click on the image for a larger version):

tracd behind an apache 2.2 proxy

The idea is pretty basic, there is an Apache server running with SSL support and accepting requests for https://my.publicname.com. It is configured to act as a reverse proxy for the server running tracd behind it, accepting requests for http://192.168.1.2:8000.

So, in the example someone could open up a browser, put https://my.publicaddress.com/project in the address/location bar and access that project trac page. The process would be:

  • 1. A request is sent to the Apache server, which will accept it and process it using the following rule in the VirtualHost configuration:

    RewriteRule ^/project/(.*) \
                http://192.168.1.2:8000/project/$1 [L,P]
    
  • 2. Another request is sent from Apache to tracd, asking for the needed data

  • 3. The data is sent back from tracd to Apache

  • 4. The data is sent back to the user, transparently (the user doesn't even know that there are more than one server serving the contents).

Nice!! but... it failed when I tried to add a ticket using a external connection. :(

Each time I tried to add a ticket, after it was added, my browser was redirected to http://192.168.1.1:8000/project/ticket/(ticketnumber) instead of https://my.publicaddress.com/project/ticket/(ticketnumber). Ugly. It seemed like trac was building the url internally and, of course, that internal url will not work from outside.

After some read-and-try, I found that the problem could be solved editing my trac env trac.ini config file, and replacing:

base_url =

[ ... ]

use_base_url_for_redirect = False

with:

base_url = /project

[ ... ]

use_base_url_for_redirect = True

This solved the problem, allowing me to use the trac instance from both within the LAN and from the outside.

Posted by wu at 16:24 | Comments (1) | Trackbacks (0)
<< Paris happiness | Main | NFS server behind a PF firewall >>
Comments
Re: tracd behind an apache2 proxy

Everybody who is proxying their web app through apache (or even other web servers) has this kind of problem. Zope solves it using the Virtual Host Monster, others have other mechanisms.

Apache also has the ProxyPassReverse directive to solve the same problem, but since it is much less flexible than rewrite rules, it often doesn't do the job.

Posted by: betabug at febrero 08,2010 09:44
Trackbacks
Please send trackback to:http://blog.e-shell.org/226/tbping
There are no trackbacks.
Post a comment