I recently installed NGINX as a reverse proxy for my apache server, to handle static files. So far so good, everything working fine, except for the fact that I cant watermark my images anymore.
My .htaccess on Apache for this was:
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
RewriteRule ^(.*)wp-content/upload/(.*\.(jpg|JPG|jpeg|png))$ $1watermark.php?src=wp-content/upload/$2
</IfModule>
This is my current vhosts nginx.conf (wich isnt working for the watermark):
server {
listen 80;
server_name mydomain.com www.mydomain.com ;
error_log /var/www/vhosts/mydomain.com/statistics/logs/error_log.nginx warn;
location / {
proxy_pass http://www.mydomain.com:8080$request_uri;
include /etc/nginx/proxy.conf;
}
location ~* ^.+\.(jpg|jpeg|gif|png|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|wav|bmp|rtf|js|ico|swf)$ {
root /var/www/vhosts/mydomain.com/httpdocs;
expires 7d;
}
#This here, isnt working#
location /wp-content/upload/ {
rewrite ^/(.*)wp-content/upload/(.*\.(jpg|JPG|jpeg|png))$ /$1watermark.php?src=wp-content/upload/$2;
}
}
But doesnt work at all. I read rewrite nginx documentation, I have been trying for several days and still, I cant find the way to make it work.
upload
vsuploads
in the nginx rewrite. Typo?