Nginx 413 request entity too large


How do I fix this problem and allow image upload upto 2MB in size using nginx web-server working in reverse proxy or stand-alone mode on Unix like operating systems?

You need to configure both nginx and php to allow upload size.

Increase "client_max_body_size" but I am unable to find nginx installed on my server.

# vi /etc/nginx/nginx.conf

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

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

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;
    fastcgi_read_timeout 300;
    #gzip  on;

    # Load config files from the /etc/nginx/conf.d directory
    # The default server is in conf.d/default.conf
    include /etc/nginx/conf.d/*.conf;
     client_max_body_size 100m;
}


to check if the config file exists, but I couldnt find it on my server.

Is there anyway to resolve this issue? Or do I have to installed nginx on my server.

EDIT:

# vi /etc/php.ini


I have made all necessary changes in my php.ini files,

.....
; Maximum size of POST data that PHP will accept.
; http://www.php.net/manual/en/ini.core.php#ini.post-max-size
post_max_size = 128M
.....
.
.
.
; Maximum allowed size for uploaded files.
; http://www.php.net/manual/en/ini.core.php#ini.upload-max-filesize
upload_max_filesize = 100M
; Maximum amount of memory a script may consume (128MB)
; http://www.php.net/manual/en/ini.core.php#ini.memory-limit
memory_limit = 128M 


Reload PHP-FPM & Nginx

Don’t forget to do this so that changes you have made will come into effect:

# service php5-fpm reload
# service nginx reload

Comments

Popular posts from this blog

Observium: Configuring Microsoft Windows 2008 Server SNMP Agent

AWS: Introduction to AWS (Amazon Web Services)

System/Server Health Status using PowerShell