Nginx as revers proxy for apache: images don't show

Hello everybody. This is my first post here.

I have a large traffic technology website and to improve performance we
are wtiching to nginx.

We want to serve static content with nginx and dynamic with apache.

The configuration is perfect, but I have a problem with images.

In my previos configuration i have this .htaccess

# $Header: /usr/local/cvsroot/dday.it/.htaccess,v 1.4 2009/11/04
23:29:51 tngsandiego Exp $
RewriteEngine On
RewriteBase /
# dday.it
RewriteCond %{HTTP_HOST} ^dday\.it
RewriteRule ^(.*)$ http://www.dday.it/$1 [R=permanent,L]
# Pages
RewriteRule ^page/(.*)/(.*)/(.*).html$ index.php?a=getp&pid=$1&p=$2
RewriteRule ^page/(.*)/(.*).html$ index.php?a=getp&pid=$1
# Tags
RewriteRule ^tag/(.*).html$ index.php?a=src&form_search_phrase=$1
# Bios
RewriteRule ^profilo/(.*)$ index.php?a=gbs&uname=$1
# Article
RewriteRule ^redazione/(.*)/(.*).html(\&(.*?)|)$
index.php?a=geti&aid=$1$3 [QSA,L]
# Article - Vodafone
RewriteRule ^redazione-vodafone/(.*)/(.*).html(\&(.*?)|)$
index.php?a=getvi&aid=$1$3
# Prodotto
RewriteRule ^prodotti/(.*)/(.*).html(\&(.*?)|)$
index.php?a=gpd&oid=$1$3
# Download-Prodotto
RewriteRule ^download/(.*)/(.*)$
index.php?a=prodotti&p=sbstrm&fname=$2&fid=$1
# Live Features
RewriteRule ^pull/(.*)/(.*)$ index.php?a=pull&p=$1&uid=$2
# Facebook
RewriteRule ^(.*)/xd_receiver.htm(.*) xd_receiver.htm
# XML Sitemap - Google
RewriteRule ^xml/sitemap.xml$ index.php?a=xml&p=google-sitemap [L]
RewriteRule ^sitemap.xml$ index.php?a=xml&p=google-sitemap
RewriteRule ^sitemap_news.xml$ index.php?a=xml&p=google-news
# XML Custom
RewriteRule ^xml/(.*).xml(\&(.*?)|)$ index.php?a=xml&p=$1$2
# RSS
RewriteRule ^rss$ index.php?a=redazione&p=rss
RewriteRule ^rss3d$ index.php?a=redazione&p=rss3d
RewriteRule ^xml-vodafone$ index.php?a=redazione&p=xml-vodafone
# Broken/Non existing images users
RewriteRule ^userFiles/gallery/users/(.*)/(.*)$
userFiles/gallery/users/$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /userFiles/gallery/users/0/(.*)$
RewriteRule .* elements/images/user_default.gif [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /userFiles/gallery/users/1/(.*)$
RewriteRule .* elements/images/user_default_f.gif [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /userFiles/gallery/products/(.*)$
RewriteRule .* elements/images/no_image.png [L]
# MANAGE ERRORS
#ErrorDocument 500 /dday.it/index.php?a=page-not-found
#ErrorDocument 404 /dday.it/index.php?a=page-not-found

I imagine that the problem is the part of the code below, because other
parts of htaccess are related to dynamic content…

# Broken/Non existing images users
RewriteRule ^userFiles/gallery/users/(.*)/(.*)$
userFiles/gallery/users/$2
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /userFiles/gallery/users/0/(.*)$
RewriteRule .* elements/images/user_default.gif [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /userFiles/gallery/users/1/(.*)$
RewriteRule .* elements/images/user_default_f.gif [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_URI} /userFiles/gallery/products/(.*)$
RewriteRule .* elements/images/no_image.png [L]

How can I pass this part to nginx? There is a tutorial to rewrite
rules?

I found a website with a translation script but it doesn’t work. :frowning:

Posted at Nginx Forum:
http://forum.nginx.org/read.php?2,162092,162092#msg-162092