Running site in a subdirectory behind apache breaks widget javascript loads

4 views
Skip to first unread message

Matt Wilson

unread,
Dec 9, 2006, 9:10:44 AM12/9/06
to TurboGears
I'm running my TG site behind apache2 in a subdirectory.

My site is at http://example.com, and I want
http://example.com/mytgproject to be my TG project.

I followed the instructions on the cherrypy wiki to set up a proxy.
Here's the relevant apache config:

<Location /mytgproject>
ProxyPass http://localhost:8080
ProxyPassReverse http://localhost:8080
RequestHeader set CP-Location /mytgproject
AllowOverride None
Order Deny,Allow
Allow from all
</Location>

Now, I can hit my TG site from either http://example.com:8080 or from
http://example.com/mytgproject. Everything works EXCEPT that widgets
try to source in javascript from the root URL of my site, not the
subdirectory.

I added this to the bottom of my app.cfg, but I don't understand what
it means, and it didn't seem to solve the problem:

[/]
base_url_filter.on = True
base_url_filter.use_x_forwarded_host = True
[P]

So, I'm out of ideas. Any help would be really useful.

TIA

Matt

Neil Ludban

unread,
Dec 9, 2006, 10:50:26 AM12/9/06
to turbo...@googlegroups.com

The only thing I've been able to make work reliably is this:

<Location /mytgproject>
ProxyPass http://localhost:8080/mytgproject
ProxyPassReverse http://localhost:8080/mytgproject
RequestHeader set CP-Location /mytgproject
</Location>

And in dev.cfg:
server.webpath = '/mytgproject'

But you also have to use ${tg.url('/foo')} everywhere to have the
server.webpath value prefixed to absolute URLs. Except when you
raise redirect('/foo'), which (incorrectly, IMHO) always does
this for you.

I also just notice that TG or CherryPy has a (mis)feature where it
will happily duplicate content for server.webpath at the root, too.
So missing tg.url()s won't matter until you access the site through
Apache.

I'm still looking for a better solution :(

Adam Jones

unread,
Dec 9, 2006, 12:25:48 PM12/9/06
to TurboGears

What would be a better solution? I can't really think of anything that
helps you get correct URLs and still makes it equally easy to reference
other parts of the site.

-Adam

Neil Ludban

unread,
Dec 9, 2006, 3:28:16 PM12/9/06
to turbo...@googlegroups.com
On Sat, 09 Dec 2006 17:25:48 +0000
Adam Jones <ajo...@gmail.com> wrote:
> Neil Ludban wrote:
...

> > <Location /mytgproject>
> > ProxyPass http://localhost:8080/mytgproject
> > ProxyPassReverse http://localhost:8080/mytgproject
> > RequestHeader set CP-Location /mytgproject
> > </Location>
> >
> > And in dev.cfg:
> > server.webpath = '/mytgproject'
> >
> > But you also have to use ${tg.url('/foo')} everywhere to have the
> > server.webpath value prefixed to absolute URLs. Except when you
> > raise redirect('/foo'), which (incorrectly, IMHO) always does
> > this for you.
...

> > I'm still looking for a better solution :(
>
> What would be a better solution? I can't really think of anything that
> helps you get correct URLs and still makes it equally easy to reference
> other parts of the site.

I haven't done enough web development to say. If this is the
Right Way, I'd be happy to provide patches and documentation to
make it work out of the box.

-Neil

Reply all
Reply to author
Forward
0 new messages