Reverse Proxy with caching
Igor Sysoev
is at rambler-co.ru
Fri Oct 30 14:10:40 MSK 2009
On Fri, Oct 30, 2009 at 06:59:32AM -0400, infestdead wrote:
> Igor Sysoev Wrote:
> -------------------------------------------------------
> > On Thu, Oct 15, 2009 at 03:17:20PM +0200, Smrchy
> > wrote:
> >
> > > Hi,
> > >
> > > i setup nginx and it's working great for us for
> > static files. I'm wondering
> > > if nginx would be suited for the following
> > scenario:
> > >
> > > We have an application server that has a lot of
> > .php files and even more
> > > static files (.gif, .jpg etc).
> > >
> > > Can i put nginx in front of if like a proxy but
> > have nginx cache the static
> > > files (everything except the .php stuff). So
> > that only .php requests reach
> > > the server and the static files will be cached
> > on the nginx machine once the
> > > get retrieved from the upstream server.
> >
> > First, you may separate static files from PHP:
> >
> > server {
> >
> > location ~ \.(gif|jpg|png)$ {
> > root /data/www;
> > }
> >
> > location ~ \.php$ {
> > proxy_pass http://backend;
> > }
> >
> > However, you have to retrieve the files by
> > yourself.
> >
> > Second, you may use mirror on demand:
> >
> > server {
> >
> > location ~ \.(gif|jpg|png)$ {
> > root /data/www;
> > error_page 404 = @fetch;
> > }
> >
> > location @fetch {
> > internal;
> >
> > proxy_pass http://backend;
> > proxy_store on;
> > proxy_store_access user:rw group:rw
> > all:r;
> > proxy_temp_path /data/temp;
> >
> > root /data/www;
> > }
> >
> > location ~ \.php$ {
> > proxy_pass http://backend;
> > }
> >
>
> When I try using proxy_pass within location ~ something I get :
> : "proxy_pass" may not have URI part in location given by regular expression, or inside named location, or inside the "if" statement, or inside the "limit_except" block in /etc/nginx/nginx.conf:52
>
> the line is proxy_pass http://127.0.0.1:8080/;
>
> Do you have an idea what the problem might be?
- proxy_pass http://127.0.0.1:8080/;
+ proxy_pass http://127.0.0.1:8080;
--
Igor Sysoev
http://sysoev.ru/en/
More information about the nginx
mailing list