Answer the question
In order to leave comments, you need to log in
nginx and some scripts
Good afternoon.
Installed nginx as frontend for apache.
I have some folder, and there are three scripts in it that should be cached (they have a lot of sql queries - and the information is rarely updated).
How to correctly compose the nginx config?
Now like this
. In this case, the problem is that /script.php and /script.php?123123123 are two different pages and are cached twice, so an attacker could easily cause a cache overflow.
server {
listen 80;
server_name ___ ___;
location / {
proxy_pass ___:8080;
proxy_cache off;
}
location /та самая папка/ {
expires 1d;
access_log off;
proxy_cache itmorating;
proxy_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$request_uri";
proxy_pass __:8080;
proxy_temp_path /data/www/;
proxy_cache_valid 200 302 10m;
proxy_cache_valid 404 10s;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header Host $host;
}
Answer the question
In order to leave comments, you need to log in
proxy_cache_key "$request_method|$http_if_modified_since|$http_if_none_match|$request_uri"; < - look here, with the same success playing with these headers does the same, so you need to cache not by the entire request URI, but only by the script name ($request_filename).
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question