K
K
KeyDel2020-01-16 14:26:46
Nginx
KeyDel, 2020-01-16 14:26:46

How to configure NGINX so that it gives the necessary types of static files to PHP processing, and does not return it on its own?

Good afternoon!
I'm trying to set up a bunch of Nginx Apache Php, a noob in these matters.
It is necessary that some types of static files (for example, xls) are transferred to the php script for processing, and not returned immediately to the client.
If I add the desired file type to the section:

location / {
  proxy_pass      http://my_host:8080;
  location ~* ^.+\.(jpeg|jpg|..список..|swf)$ {
    root           path_to_site/public_html;
    expires        max;
    try_files      $uri @fallback;
  }
}

then, the file is returned by Nginx (as I understand it) and the file does not get into the php script. If I remove the desired type from the list, then when I call, I get 403.
Tell me how to overcome the problem?
Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
K
ky0, 2020-01-16
@ky0

Nested locations are useless here - everything is the opposite for you, files with extensions are processed by nginx, and the rest goes to Apache.
If Apache is in charge of PHP processing, it is enough to leave the location with proxying to it. All received errors will be from within, and not from nginx.

A
Alexey Dmitriev, 2020-01-16
@SignFinder

If you have already passed php to some handler - for example php-fpm or mod-php in apache, then all you need is to find location ~ \.php$ and make it look like location ~ \.xls$

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question