Welcome! Log In Create A New Profile

Advanced

limit_req is limiting requests outside of location block it is applied to

March 11, 2016 07:33AM
I have a location ~* \.php$ with limit_req set inside it. But requests outside of this location block, e.g. for .js and .css files are also being limited. I only want to limit the number of requests to .php files.

This is my config:

worker_processes 2;

pid logs/nginx.pid;

events {
worker_connections 1024;
}

http {
include mime.types;
default_type application/octet-stream;

server_names_hash_bucket_size 128;

sendfile on;
keepalive_timeout 10 10;

port_in_redirect off;

#Fix IP address
set_real_ip_from 127.0.0.1;
real_ip_header X-Forwarded-For;

limit_req_zone $binary_remote_addr zone=one:10m rate=1r/s;

log_format main '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent "$http_referer" '
'"$http_user_agent"';

server {
listen 7776;
server_name www.test.com;
access_log logs/test.log main;
error_log logs/test-error.log warn;
root /path/to/test.com;

location / {
index index.php;
try_files $uri $uri/ /index.php?$args;
}

# Pass PHP scripts on to PHP-FPM
location ~* \.php$ {
limit_req zone=one burst=5;
try_files $uri =404;
include fastcgi_params;
fastcgi_pass unix:/path/to/php.sock;
}
}
}
Subject Author Posted

limit_req is limiting requests outside of location block it is applied to

djeyewater March 11, 2016 07:33AM

Re: limit_req is limiting requests outside of location block it is applied to

djeyewater March 11, 2016 08:17AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 254
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready