Skip to main content
se añadió 1 carácter en el cuerpo
Origen Enlace
Jbeltran
  • 766
  • 5
  • 15
 include /etc/Nginx/conf.d/*.conf;
    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;

    events {
            worker_connections 768;
            multi_accept on;
    }

    http {
        map $remote_addr $ip_anonym1 {
        default 0.0.0;
        "~(?P<ip>(\d+)\.(\d+)\.(\d+))\.\d+" $ip;
        "~(?P<ip>[^:]+:[^:]+):" $ip;
    }

    map $remote_addr $ip_anonym2 {
        default .0;
        "~(?P<ip>(\d+)\.(\d+)\.(\d+))\.\d+" .0;
        "~(?P<ip>[^:]+:[^:]+):" ::;
    }

    map $ip_anonym1$ip_anonym2 $ip_anonymized {
        default 0.0.0.0;
        "~(?P<ip>.*)" $ip;
    }

    log_format anonymized '$ip_anonymized - $remote_user [$time_local] '
    '"$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent"';


        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 15;
        types_hash_max_size 2048;
        server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 2;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;


    server {
        #Configuración de puerto
            listen 80;
            listen [::]:80 default_server;
            server_name _;
            return 444;

            client_body_buffer_size 16k;

            root /local;

        #Ubicación por defecto de los logs
            access_log /var/www/log/access.log;
            error_log /var/www/log/error.log;

        #Configuración para archivos robots.txt
            location = /robots.txt {
                    allow all;
                    log_not_found off;
                    access_log off;
            }

        #Denegar acceso a archivos txt o de logs
            location ~* \.(txt|log)$ {
                    deny all;
            }

        #Denegar acceso a cuaqluier script php dentro de rutas aparte a index.php
            location ~ \..*/.*\.php$ {
                    return 403;
            }

        #Denegar acceso a directorios privados
            location ~ ^/sites/.*/private/ {
                    return 403;
            }

        #Responder la aplicación unicamente por el archivo index.php interpretando parametros querystring
            location / {
                    proxy_read_timeout 300000;
                    location ~* ^(?:.+\.(?:htaccess|make|txt|engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(?:\.php)?|xtmpl)|code-style\.pl|/Entries.*|/Repository|/Root|/Tag|/Template)$ {
                            return 404;
                    }
                    try_files $uri /index.php?$query_string;
            }

        #Condigo para interpretación de lenguaje PHP.
            location ~ '\.php$|^/update.php' {
                    fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
                    include fastcgi_params;
                    fastcgi_param HTTP_PROXY "";
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_param PATH_INFO $fastcgi_path_info;
                    fastcgi_param QUERY_STRING $query_string;
                    fastcgi_param BASE_PATH $document_root;
                    fastcgi_intercept_errors on;
                    fastcgi_read_timeout 3600;
                    fastcgi_param   SERVER_NAME $server_name;
                    keepalive_timeout 0;
                    fastcgi_buffers 32 32k;
                    fastcgi_buffer_size 64k;
                    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            }

    client_max_body_size 50;50M;

    }
 include /etc/Nginx/conf.d/*.conf;
    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;

    events {
            worker_connections 768;
            multi_accept on;
    }

    http {
        map $remote_addr $ip_anonym1 {
        default 0.0.0;
        "~(?P<ip>(\d+)\.(\d+)\.(\d+))\.\d+" $ip;
        "~(?P<ip>[^:]+:[^:]+):" $ip;
    }

    map $remote_addr $ip_anonym2 {
        default .0;
        "~(?P<ip>(\d+)\.(\d+)\.(\d+))\.\d+" .0;
        "~(?P<ip>[^:]+:[^:]+):" ::;
    }

    map $ip_anonym1$ip_anonym2 $ip_anonymized {
        default 0.0.0.0;
        "~(?P<ip>.*)" $ip;
    }

    log_format anonymized '$ip_anonymized - $remote_user [$time_local] '
    '"$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent"';


        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 15;
        types_hash_max_size 2048;
        server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 2;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;


    server {
        #Configuración de puerto
            listen 80;
            listen [::]:80 default_server;
            server_name _;
            return 444;

            client_body_buffer_size 16k;

            root /local;

        #Ubicación por defecto de los logs
            access_log /var/www/log/access.log;
            error_log /var/www/log/error.log;

        #Configuración para archivos robots.txt
            location = /robots.txt {
                    allow all;
                    log_not_found off;
                    access_log off;
            }

        #Denegar acceso a archivos txt o de logs
            location ~* \.(txt|log)$ {
                    deny all;
            }

        #Denegar acceso a cuaqluier script php dentro de rutas aparte a index.php
            location ~ \..*/.*\.php$ {
                    return 403;
            }

        #Denegar acceso a directorios privados
            location ~ ^/sites/.*/private/ {
                    return 403;
            }

        #Responder la aplicación unicamente por el archivo index.php interpretando parametros querystring
            location / {
                    proxy_read_timeout 300000;
                    location ~* ^(?:.+\.(?:htaccess|make|txt|engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(?:\.php)?|xtmpl)|code-style\.pl|/Entries.*|/Repository|/Root|/Tag|/Template)$ {
                            return 404;
                    }
                    try_files $uri /index.php?$query_string;
            }

        #Condigo para interpretación de lenguaje PHP.
            location ~ '\.php$|^/update.php' {
                    fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
                    include fastcgi_params;
                    fastcgi_param HTTP_PROXY "";
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_param PATH_INFO $fastcgi_path_info;
                    fastcgi_param QUERY_STRING $query_string;
                    fastcgi_param BASE_PATH $document_root;
                    fastcgi_intercept_errors on;
                    fastcgi_read_timeout 3600;
                    fastcgi_param   SERVER_NAME $server_name;
                    keepalive_timeout 0;
                    fastcgi_buffers 32 32k;
                    fastcgi_buffer_size 64k;
                    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            }

    client_max_body_size 50;

    }
 include /etc/Nginx/conf.d/*.conf;
    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;

    events {
            worker_connections 768;
            multi_accept on;
    }

    http {
        map $remote_addr $ip_anonym1 {
        default 0.0.0;
        "~(?P<ip>(\d+)\.(\d+)\.(\d+))\.\d+" $ip;
        "~(?P<ip>[^:]+:[^:]+):" $ip;
    }

    map $remote_addr $ip_anonym2 {
        default .0;
        "~(?P<ip>(\d+)\.(\d+)\.(\d+))\.\d+" .0;
        "~(?P<ip>[^:]+:[^:]+):" ::;
    }

    map $ip_anonym1$ip_anonym2 $ip_anonymized {
        default 0.0.0.0;
        "~(?P<ip>.*)" $ip;
    }

    log_format anonymized '$ip_anonymized - $remote_user [$time_local] '
    '"$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent"';


        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 15;
        types_hash_max_size 2048;
        server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 2;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;


    server {
        #Configuración de puerto
            listen 80;
            listen [::]:80 default_server;
            server_name _;
            return 444;

            client_body_buffer_size 16k;

            root /local;

        #Ubicación por defecto de los logs
            access_log /var/www/log/access.log;
            error_log /var/www/log/error.log;

        #Configuración para archivos robots.txt
            location = /robots.txt {
                    allow all;
                    log_not_found off;
                    access_log off;
            }

        #Denegar acceso a archivos txt o de logs
            location ~* \.(txt|log)$ {
                    deny all;
            }

        #Denegar acceso a cuaqluier script php dentro de rutas aparte a index.php
            location ~ \..*/.*\.php$ {
                    return 403;
            }

        #Denegar acceso a directorios privados
            location ~ ^/sites/.*/private/ {
                    return 403;
            }

        #Responder la aplicación unicamente por el archivo index.php interpretando parametros querystring
            location / {
                    proxy_read_timeout 300000;
                    location ~* ^(?:.+\.(?:htaccess|make|txt|engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(?:\.php)?|xtmpl)|code-style\.pl|/Entries.*|/Repository|/Root|/Tag|/Template)$ {
                            return 404;
                    }
                    try_files $uri /index.php?$query_string;
            }

        #Condigo para interpretación de lenguaje PHP.
            location ~ '\.php$|^/update.php' {
                    fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
                    include fastcgi_params;
                    fastcgi_param HTTP_PROXY "";
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_param PATH_INFO $fastcgi_path_info;
                    fastcgi_param QUERY_STRING $query_string;
                    fastcgi_param BASE_PATH $document_root;
                    fastcgi_intercept_errors on;
                    fastcgi_read_timeout 3600;
                    fastcgi_param   SERVER_NAME $server_name;
                    keepalive_timeout 0;
                    fastcgi_buffers 32 32k;
                    fastcgi_buffer_size 64k;
                    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            }

    client_max_body_size 50M;

    }
Origen Enlace
Jbeltran
  • 766
  • 5
  • 15

La directiva client_max_body_size la debes establecer en la seccion http, server o location - no en todas - del archivo nginx.conf. En el contexto http se aplica a todas las aplicacion del servidor nginx, por ejemplo:

http {
...
client_max_body_size 50M;
}  

en el contexto server se aplica a un sitio en concreto

server {
...
client_max_body_size 50M;
}  

para aplicarlo a una sola ruta en especifico se haria

location /upload {
...
client_max_body_size 50M;
}  

Ahora bien, revisando tu archivo veo que tienes la directiva regada por todas las secciones, solo bastaria con colocarla en la seccion http para cubrir todos los servers y las rutas. Aca te dejo tu archivo modificado

 include /etc/Nginx/conf.d/*.conf;
    user www-data;
    worker_processes auto;
    pid /run/nginx.pid;

    events {
            worker_connections 768;
            multi_accept on;
    }

    http {
        map $remote_addr $ip_anonym1 {
        default 0.0.0;
        "~(?P<ip>(\d+)\.(\d+)\.(\d+))\.\d+" $ip;
        "~(?P<ip>[^:]+:[^:]+):" $ip;
    }

    map $remote_addr $ip_anonym2 {
        default .0;
        "~(?P<ip>(\d+)\.(\d+)\.(\d+))\.\d+" .0;
        "~(?P<ip>[^:]+:[^:]+):" ::;
    }

    map $ip_anonym1$ip_anonym2 $ip_anonymized {
        default 0.0.0.0;
        "~(?P<ip>.*)" $ip;
    }

    log_format anonymized '$ip_anonymized - $remote_user [$time_local] '
    '"$request" $status $body_bytes_sent '
    '"$http_referer" "$http_user_agent"';


        ##
        # Basic Settings
        ##

        sendfile on;
        tcp_nopush on;
        tcp_nodelay on;
        keepalive_timeout 15;
        types_hash_max_size 2048;
        server_tokens off;

        # server_names_hash_bucket_size 64;
        # server_name_in_redirect off;

        include /etc/nginx/mime.types;
        default_type application/octet-stream;

        ##
        # SSL Settings
        ##

        ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
        ssl_prefer_server_ciphers on;

        ##
        # Logging Settings
        ##

        access_log /var/log/nginx/access.log;
        error_log /var/log/nginx/error.log;

        ##
        # Gzip Settings
        ##

        gzip on;
        gzip_disable "msie6";

        # gzip_vary on;
        gzip_proxied any;
        gzip_comp_level 2;
        # gzip_buffers 16 8k;
        # gzip_http_version 1.1;
        gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

        ##
        # Virtual Host Configs
        ##

        include /etc/nginx/conf.d/*.conf;
        include /etc/nginx/sites-enabled/*;


    server {
        #Configuración de puerto
            listen 80;
            listen [::]:80 default_server;
            server_name _;
            return 444;

            client_body_buffer_size 16k;

            root /local;

        #Ubicación por defecto de los logs
            access_log /var/www/log/access.log;
            error_log /var/www/log/error.log;

        #Configuración para archivos robots.txt
            location = /robots.txt {
                    allow all;
                    log_not_found off;
                    access_log off;
            }

        #Denegar acceso a archivos txt o de logs
            location ~* \.(txt|log)$ {
                    deny all;
            }

        #Denegar acceso a cuaqluier script php dentro de rutas aparte a index.php
            location ~ \..*/.*\.php$ {
                    return 403;
            }

        #Denegar acceso a directorios privados
            location ~ ^/sites/.*/private/ {
                    return 403;
            }

        #Responder la aplicación unicamente por el archivo index.php interpretando parametros querystring
            location / {
                    proxy_read_timeout 300000;
                    location ~* ^(?:.+\.(?:htaccess|make|txt|engine|inc|info|install|module|profile|po|sh|.*sql|theme|tpl(?:\.php)?|xtmpl)|code-style\.pl|/Entries.*|/Repository|/Root|/Tag|/Template)$ {
                            return 404;
                    }
                    try_files $uri /index.php?$query_string;
            }

        #Condigo para interpretación de lenguaje PHP.
            location ~ '\.php$|^/update.php' {
                    fastcgi_split_path_info ^(.+?\.php)(|/.*)$;
                    include fastcgi_params;
                    fastcgi_param HTTP_PROXY "";
                    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
                    fastcgi_param PATH_INFO $fastcgi_path_info;
                    fastcgi_param QUERY_STRING $query_string;
                    fastcgi_param BASE_PATH $document_root;
                    fastcgi_intercept_errors on;
                    fastcgi_read_timeout 3600;
                    fastcgi_param   SERVER_NAME $server_name;
                    keepalive_timeout 0;
                    fastcgi_buffers 32 32k;
                    fastcgi_buffer_size 64k;
                    fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
            }

    client_max_body_size 50;

    }