Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1213 (closed defect: fixed)

Opened 11 years ago

Last modified 10 years ago

incomplete support for changing server.webpath

Reported by: nludban Owned by: jorge.vargas
Priority: normal Milestone: 1.0.2
Component: unassigned Version: 1.0b2
Severity: normal Keywords:
Cc:

Description

A TG quickstart application doesn't work out of the box when the application root is changed (eg, proxied behind Apache as part of a larger site).

Several issues to be resolved:

  1. master.kid does not use tg.url(), so images are not shown in the welcome page
  2. /index needs to be redirected, otherwise relative link errors are silently caught by Apache
  3. raise redirect('/foo') implies redirect(url('/foo')), which prevents the TG app from redirecting to other parts of the larger site
  4. documentation needed for recommended and consistent proxy configuration
  5. setting server.webpath should return errors for requests outside webpath, that way missing tg.url()s can be caught in standalone mode before moving behind Apache
  6. set server.webpath by default so TG developers and users are aware of the requirements for moving the application root

I'm working on patches, will add them when tested.

Attachments

master.kid.diff Download (1.5 KB) - added by nludban 11 years ago.
patch for master.kid

Change History

Changed 11 years ago by nludban

patch for master.kid

comment:1 Changed 11 years ago by nludban

Recommended setup instructions...

Configure Apache (httpd.conf) to proxy everything under /mytgproject to the TG server:

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

Configure TG (dev.cfg) so it knows how it's being accessed:

server.webpath = '/mytgproject'

Note that both Apache and TG agree on the application root. Access should work consistently whether being proxied through Apache or testing against the CherryPy? server directly.

Now use ${tg.url('/foo')} in all templates to have the server.webpath value prefixed to absolute (relative to the TG project) URLs.

comment:2 Changed 11 years ago by khorn

I've also been testing this...here are my results:

  • master.kid changes mostly work, though I couldn't get the @import to work for the stylesheet. I was going pretty fast though, and I may have just fat-fingered something. In the interests of time, I ended up just pulling in the stylesheet using a <link> tag rather than using @import.
  • when saving a page, the redirect seems to apply the server.webpath twice...so instead of redirecting to  http://testhost.com/pp/wiki20/PageName, instead I'm being redirected to  http://testhost.com/pp/wiki20/pp/wiki20/PageName. I haven't figured out what is causing this yet.

btw, my Apache setup looks something like:

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

which is a little different than what was shown above, which may be causing the redirect problem...

while typing this comment, I tried changing the Apache setup to:

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

and that solved the redirect problem, but I thought I'd put it up here, in case someone else might find it useful.

Good Work, Niel!

comment:3 in reply to: ↑ description Changed 11 years ago by alberto

Replying to nludban:

A TG quickstart application doesn't work out of the box when the application root is changed (eg, proxied behind Apache as part of a larger site).

Several issues to be resolved:

  1. master.kid does not use tg.url(), so images are not shown in the welcome page

Thanks for the patch. I'll commit that if no one does before when I have a chance.

  1. /index needs to be redirected, otherwise relative link errors are silently caught by Apache

I'm not sure what you mean here... you mean trailing slash issues?

  1. raise redirect('/foo') implies redirect(url('/foo')), which prevents the TG app from redirecting to other parts of the larger site

Hmm, maybe an "absoulte=False" kw. param to redirect would do. If "True" then the url shouldn't be filtered by "url"

  1. documentation needed for recommended and consistent proxy configuration

Agree

  1. setting server.webpath should return errors for requests outside webpath, that way missing tg.url()s can be caught in standalone mode before moving behind Apache

Agree

  1. set server.webpath by default so TG developers and users are aware of the requirements for moving the application root

Agree

I'm working on patches, will add them when tested.

Much appreciated! Thanks :) If you also include some unit-tests it would be awesome. That will make sure no regressions get in when we start moving towards 2.0.

Alberto

comment:4 Changed 11 years ago by jorge.vargas

  • Milestone set to 1.0.2

comment:5 Changed 11 years ago by jorge.vargas

  • Owner changed from anonymous to jorge.vargas

comment:6 Changed 11 years ago by jorge.vargas

  • Status changed from new to closed
  • Resolution set to fixed

fixed in r2528 and r2529, thanks

Note: See TracTickets for help on using tickets.