WSGIScriptAlias and static files

113 views
Skip to first unread message

Walter Cruz

unread,
Sep 12, 2008, 10:45:13 AM9/12/08
to mod...@googlegroups.com
Hi all.

I have setted a subdomain, serving a little pylons app.

My setting is:

WSGIScriptAlias / /path/to/my.wsgi

It's all ok, but there's a questions: my static files are beign served
though pylons, not apache.

How can I make the WSGIScriptAlias not match css and html files?

[]'s
- Walter

Carl Nobile

unread,
Sep 12, 2008, 11:02:34 AM9/12/08
to mod...@googlegroups.com
You could try WSGIScriptAliasMatch instead of WSGIScriptAlias, but I don't see how you could be picking up anything other than 'my.wsgi' based on your how you have your path defined.

http://code.google.com/p/modwsgi/wiki/ConfigurationDirectives#WSGIScriptAliasMatch

If you define the full filename like you did, it should not be matching *.css or *.html files. WSGIScriptAlias will match exactly what you define since it does not use and globbing or regex.

-Carl
--
-------------------------------------------------------------------------------
Carl J. Nobile (Software Engineer)
carl....@gmail.com
-------------------------------------------------------------------------------

Clodoaldo Pinto Neto

unread,
Sep 12, 2008, 12:17:37 PM9/12/08
to mod...@googlegroups.com
2008/9/12 Walter Cruz <walte...@gmail.com>:

Create a directory for public static files and then set it up:

<Directory /var/www/html/my_sites_root/public>
SetHandler default-handler
</Directory>

Regards, Clodoaldo Pinto Neto

>
> []'s
> - Walter
>
> >
>

Jorge Vargas

unread,
Sep 12, 2008, 12:17:21 PM9/12/08
to mod...@googlegroups.com
One solution is to create aliases that will match the static files
before the WSGIScriptAlias is invoked.
Check out the section "Mounting as root of site"
http://code.google.com/p/modwsgi/wiki/QuickConfigurationGuide

I don't find the above optimal as it means a lot of work on
deployment, I'll be happy if someone points me a better way.

> []'s
> - Walter
>
> >
>

Graham Dumpleton

unread,
Sep 12, 2008, 6:25:59 PM9/12/08
to mod...@googlegroups.com
2008/9/13 Jorge Vargas <jorge....@gmail.com>:

For that, see mod_rewrite example for .htaccess file in:

http://code.google.com/p/modwsgi/wiki/ConfigurationGuidelines

This could also be done in Directory container in main Apache configuration.

This approach gives precedence to static files. On if no matched
static file does it get passed to WSGI application.

That document has other static file examples as well.

Graham

Luis Bruno

unread,
Sep 14, 2008, 5:54:26 PM9/14/08
to mod...@googlegroups.com
Em 12-09-2008 17:17, Jorge Vargas escreveu:
> One solution is to create aliases that will match the static files
> before the WSGIScriptAlias is invoked.

I've recently used:
WSGIScriptAliasMatch /(?!svn) /trac/app.wsgi

That's how I ended up serving <Location /svn> through mod_dav_svn, while
having the rest being handed-off to Trac.

I was hoping that having WSGIScriptAliasMatch / /trac/app.wsgi after <Location
/svn> would decrease its precedence. Got bitten by that assumption, and then I
found out about negative lookahead in regexes.

This helps?
--
Luis "Happy, happy mod_wsgi user" Bruno

Graham Dumpleton

unread,
Sep 14, 2008, 7:08:15 PM9/14/08
to mod...@googlegroups.com
2008/9/15 Luis Bruno <m...@lbruno.org>:

I'll have to look up how that pattern works, but I would be a little
bit careful with it.

The reason is that WSGI applications are separated into different
Python interpreter instances based on the mount point. If the pattern
for a WSGIScriptAliasMatch targeted at a single WSGI script file can
match multiple URLs, then each of the matched URLs may end up being
dispatched to a different Python interpreter instances. This would be
reflected by SCRIPT_NAME being different for different URLs.

As well as causing distinct interpreters for each match URL, that
SCRIPT_NAME can be different may confuse some WSGI applications as
effective mount point will keep changing.

I'll have to remember to do some experimentation with this one.

Graham

Luis Bruno

unread,
Sep 15, 2008, 5:06:10 AM9/15/08
to mod...@googlegroups.com
Em 15-09-2008 0:08, Graham Dumpleton escreveu:
> 2008/9/15 Luis Bruno <m...@lbruno.org>:

> > I was hoping that having WSGIScriptAliasMatch / /trac/app.wsgi after <Location
> > /svn> would decrease its precedence.
>
> I'll have to look up how that pattern works, but I would be a little
> bit careful with it.

I should write more carefully: I'm using WSGIScriptAliasMatch now; at the time
I was testing, that was a WSGIScriptAlias; no regexes involved.

> As well as causing distinct interpreters for each match URL, that
> SCRIPT_NAME can be different may confuse some WSGI applications as
> effective mount point will keep changing.

I vaguely remember that part of the docs. I think this didn't bite me because
I blindly copied "WSGIApplicationGroup %{GLOBAL}" inside <Directory /trac>, right?


Graham Dumpleton

unread,
Sep 15, 2008, 6:15:23 AM9/15/08
to mod...@googlegroups.com
2008/9/15 Luis Bruno <m...@lbruno.org>:

That would certainly ensure it wouldn't be an issue, but as it turns
out my concerns were unwarranted anyway. That pattern always result in
same value of SCRIPT_NAME anyway.

Graham

Reply all
Reply to author
Forward
0 new messages