On Tue, 2008-01-22 at 19:37 -0800, Mike Orr wrote:
> You'll have to set up a handler for each file/directory in public if you want 
> to
> do this, or put everything in a subdirectory of public which will appear in 
> the
> URL (public/static/images -> /static/images).  Unless there's a way to make
> Apache fall back to the application if a static file doesn't exist.
> 
> It's not well documented how to do this.  You're not actually setting
> up a handler for the static files.  You're setting up a handler for
> the Pylons app and then disabling it for certain sub-URLs.  With
> mod_proxy it would be:
> 
> DocumentRoot   /myapp/myapp/public
> ProxyPass        /             http://127.0.0.1:8080/
> ProxyPass        /images   !
> 
> With mod_scgi you'd do something like:
> 
> <Location /images>
>     SCGIHandler Off
> </Location>
> 
> Each handler has a different way to disable itself.  There may be some
> that can't be disabled at all.

I don't use Apache, but here's what I would do in Nginx:

server {
    listen 1.2.3.4:80; 
    server_name www.example.com;
    error_page 404  /404; # goes to Pylons app

    location / {
        proxy_pass http://127.0.0.1:8000$request_uri;
        include /etc/nginx/proxy.conf;
    }

    # static files location
    location ~* ^/(static|images|javascript|js|css|flash|media|
downloads)/$ {
        root /path/to/public;
    }
}

and my directory layout just looks like:

/path/to/public/static
/path/to/public/images 

etc.


If you wanted to preserve the requested URI to pass to your controller,
you could use a conditional redirect instead: 

server {
    listen 1.2.3.4:80; 
    server_name www.example.com;
    
    location / {
        proxy_pass http://127.0.0.1:8000$request_uri;
        include /etc/nginx/proxy.conf;
    }

    # static files location
    location ~* ^/(static|images|javascript|js|css|flash|media|downloads)/$ {
        root /path/to/public;
        if (!-f $request_filename) {
            rewrite (.*) /404?page=$request_uri redirect;
        }
    }
}

Personally, I let Nginx handle 404's for the most part.  Bots (most of
them checking for hackable versions of PHP apps it seems) can generate a
ton of 404's.

Hope that helps someone.


Regards, 
Cliff


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"pylons-discuss" group.
To post to this group, send email to pylons-discuss@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/pylons-discuss?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to