N
N
noprof2014-12-11 20:08:02
Nginx
noprof, 2014-12-11 20:08:02

Nginx if file not found, pass request to php script, how?

In general, in short:
There is a certain application that extracts files from a specific archive. The extractor is written in php and works as follows:
1.) There is a transition to some resource in the browser, for example, to domain.com/data/file.txt
2.) The web server crawls into /data/file.txt if the file is found - it just gives it back.
3.) If the file is not found, then /client/index.php (aka extractor) is called with the link parameter of the file not found.
Those. a request is made to nginx
domain.com/somefolder/blabla.bmp
nginx went to /somefolder and did not find blabla.bmp
Nginx, due to the fact that it did not find blabla.bmp, should call /client/index.php in the argument of the file not found so that /client/index.php can open the archives that are embedded in its logic, find the necessary file, and extract it into folder, and after that display.
There is no easier way to describe the situation.
There are no problems under Apache, the options are used there: AllowOverride All (ie read .htaccess) which says: ErrorDocument 404 /client/index.php and that's it. And this drives me into a stupor, and no extra. no changes need to be made anywhere.
Question: how to organize all of the above under nginx + php5-fpm?
PS (here we are talking about the browser version of the client to one MMORPG ( https://github.com/vthibault/roBrowser))
PS link to their .htaccess
PS link to the extractor /client/index.php
Help please.
PS I'm thinking about try_files, but I can't figure it out yet...
Help :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vitaliy, 2014-12-11
@omsknews

well something like this
location /
{
try_files $uri $uri/ /client/index.php;
}
location ~ \.php$ {.
include fastcgi_params;.
fastcgi_pass unix:/tmp/php-fpm.socket;.
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
location ~ /\.ht { deny all;}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question