php – Nginx错误413

前端之家收集整理的这篇文章主要介绍了php – Nginx错误413前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
当我尝试将文件上传到我的网站时,我得到了Nginx“413请求实体太大”的错误,但是在我的Nginx.conf文件中,我已经明确地将最大大小约为250MB,并更改了PHP.ini中的最大文件大小(是的,我重新启动了进程).错误日志告诉我:

2010/12/06 04:15:06 [error] 20124#0:
*11975 client intended to send too large body: 1144149 bytes,client:
60.228.229.238,server: www.x.com,request: “POST
/upload HTTP/1.1”,host:
“x.com”,referrer:
“http://x.com/”

据我所知,1144149字节不是250MB …
有没有我在这里失踪的东西?

这是Nginx的基本配置:

  1. user Nginx;
  2. worker_processes 8;
  3. worker_rlimit_nofile 100000;
  4.  
  5. error_log /var/log/Nginx/error.log;
  6. #error_log /var/log/Nginx/error.log notice;
  7. #error_log /var/log/Nginx/error.log info;
  8.  
  9. pid /var/run/Nginx.pid;
  10.  
  11.  
  12. events {
  13. worker_connections 1024;
  14. use epoll;
  15. }
  16.  
  17.  
  18. http {
  19. include /etc/Nginx/mime.types;
  20. default_type application/octet-stream;
  21.  
  22. log_format main '$remote_addr - $remote_user [$time_local] "$request" '
  23. '$status $body_bytes_sent "$http_referer" '
  24. '"$http_user_agent" "$http_x_forwarded_for"';
  25.  
  26. access_log /var/log/Nginx/access.log main;
  27.  
  28. sendfile on;
  29. client_max_body_size 300M;
  30. tcp_nopush on;
  31. tcp_nodelay on;
  32. server_tokens off;
  33. gzip on;
  34. gzip_static on;
  35. gzip_comp_level 5;
  36. gzip_min_length 1024;
  37. keepalive_timeout 300;
  38. limit_zone myzone $binary_remote_addr 10m;
  39.  
  40. # Load config files from the /etc/Nginx/conf.d directory
  41. include /etc/Nginx/sites/*;
  42. }

和网站的vhost:

  1. server {
  2. listen 80;
  3. server_name www.x.com x.com;
  4.  
  5. access_log /var/log/Nginx/x.com-access.log;
  6.  
  7. location / {
  8. index index.html index.htm index.PHP;
  9. root /var/www/x.com;
  10.  
  11. if (!-e $request_filename) {
  12. rewrite ^/([a-z,0-9]+)$/$1.PHP last;
  13. rewrite ^/file/(.*)$/file.PHP?file=$1;
  14. }
  15.  
  16. location ~ /engine/.*\.PHP${
  17. return 404;
  18. }
  19.  
  20. location ~ ^/([a-z,0-9]+)\.PHP${
  21. fastcgi_pass 127.0.0.1:9000;
  22. fastcgi_index index.PHP;
  23. fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
  24. include fastcgi_params;
  25. }
  26. }
  27. }
不知道您的Nginx版本的版本以及它们所构建的模块是如何变得非常困难的,但请尝试以下操作:

>复制你的client_max_body_size 300M;进入vhost配置的位置/ {}部分.我不知道它是否正确覆盖了默认值(1 MB).
你使用nginx_upload_module吗?如果是,请确保你有upload_max_file_size 300MB;在你的配置中也行.

猜你在找的PHP相关文章