apache, nginx reverse proxy and zenphoto

I'm running apache2 with nginx as a reverse proxy on my Linode 360. This is my nginx config:

server {

            listen   80;
            server_name  server.com;
            rewrite ^/(.*) http://www.server.com/$1 permanent;

           }

server {

    listen   80;
    server_name www.server.com;

    access_log /home/user/public_html/server.com/log/access.log;
    error_log /home/user/public_html/server.com/log/error.log;

    location / {
        proxy_pass http://127.0.0.1:8080;
    }

   location ~* ^.+.(jpe?g|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|avi|mp3)$ {
        expires 30d;
        root /home/user/public_html/server.com/public/;
    }

}

This works great, except that I am trying to install ZenPhoto and it uses mod_rewrite to change image links from something like:

http://www.site.com/portfolio/folder/image/500/imagename.jpg

To:

http://www.site.com/portfolio/albums/folder/imagename.jpg

What I need to do is exclude from the proxy jpg files that are in the portfolio folder and have "image" in the url.

I found one person who did a complete set of nginx rules for ZenPhoto here.

These lines seem relevant:

rewrite "^/(.*)/image/(thumb|[0-9]{1,4})/([^/\\\]+)$"  /zp-core/i.php?a=$1&i=$3&s=$2  last;
rewrite ^/(.*)/image/([^/\\\]+)$  /zp-core/i.php?a=$1&i=$2  last;

Any ideas?

Thanks!

1 Reply

I think I'm going to need to do some regular expression homework — it's been a while — but this seems to have done the trick:

    location ~* ^/((?!portfolio).).+.((?!image|album).).+.(jpe?g) {
        expires 30d;
        root /home/user/public_html/site.com/public/;
    }

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct