This is what I am trying to do. I am not familiar with Nginx enough to create custom rewrite rules like you can with Apache. It would be greatly appreciated if someone could help me with the Nginx config file! Thank you in advance!
I have an image server running Nginx on port 80 and Apache listening on 8080. What I would like to do is...
when you request an image that does not exist like so:
http://img.server.com/(...ANY DIRECTORY...)/123_4_anyimagename.jpg
it will redirect to
http://img.server.com:8080/image.php?id=123_4_anyimagename
Thank you! I almost have this working! I had to put in the root
location ~ \.(gif|jpg|png)${
root /var/www/mysite.com/httpdocs/;
try_files $uri @img_proxy
}
location @img_proxy {
rewrite ^(.*)$ /image.php?id=$1
proxy_pass http://127.0.0.1:8080;
}
So in images.php file which is located at
/var/www/mysite.com/httpdocs/image.php
I simply have
<?php echo "test"; ?>
to see if its working. The problem seems to be php is not kicking in and its just rendering as plain text. Its almost there! Any clues as to where to look?
If I run http://mydomain.com:8080/image.php
I get "test" as the output. So I know php is working. What am I overlooking?