i want enable large file uploads single location, , location rewritten location. seems rewrite resetting other configurations.
my config:
server { listen 80; server_name example.com; root /var/www; index index.php; # location requires large file upload location /upload { client_max_body_size 512m; rewrite ^(.*)$ /index.php?request=$1 last; } # other locations location / { rewrite ^(.*)$ /index.php?request=$1 last; } # pass php scripts fpm location ~ \.php$ { include /etc/nginx/includes/php; } } if move client_max_body_size out of location , server, works.
if put in both location /upload , location ~ \.php$, works. don't want other locations able upload large files.
i thinking direct php directly in location /upload, once run rewrite location anyway. mean have have 2 separate locations php scripts? there way make client_max_body_size retain through other locations after rewrite?
if need specific client_max_body_size needs set within (or inherited by) location processes final uri. in case, location ~ \.php$.
as indicate in question, simplest solution process php file in location /upload. easy achieve, have php configuration in separate include file.
either rewrite ... break; or overriding 2 of fastcgi_param directives should work you:
option 1:
location /upload { client_max_body_size 512m; rewrite ^(.*)$ /index.php?request=$1 break; include /etc/nginx/includes/php; } see this document details.
option 2:
location /upload { client_max_body_size 512m; include /etc/nginx/includes/php; fastcgi_param query_string request=$uri&$query_string; fastcgi_param script_filename $document_root/index.php; }
Comments
Post a Comment