歡迎您光臨本站 註冊首頁

nginx 以fastcgi模式處理php multipart/form-data的問題

←手機掃碼閱讀     火星人 @ 2014-03-04 , reply:0

nginx 以fastcgi模式處理php multipart/form-data的問題

遇到個問題,nginx 在處理php的multipart/form-data類型的文件上傳,始終就沒有成功。我根據官方使用了NginxHttpUploadProgressModule
模塊。可是官方的配置文檔有點看不明白http {
       
  # reserve 1MB under the name 'proxied' to track uploads
  upload_progress proxied 1m;

  server {
    listen       127.0.0.1 default;
    server_name  _ *;
               
    root /path/to/root;

    location / {
      # proxy to upstream server
      proxy_pass http://127.0.0.1;
      proxy_redirect default;
       
      # track uploads in the 'proxied' zone
      # uploads expires 30s after they finish.
      track_uploads proxied 30s;
    }
               
    location ^~ /progress {
      # report uploads tracked in the 'proxied' zone
      report_uploads proxied;
    }
  }我現在在使用一套圖片庫的程序,怎麼調整配置也弄不好。來請教達人賜教!
主要不太明白的地方location ^~ /progress 這個progress哪裡來的?我就一定要這麼寫么?還是這部分根據代碼有關係?
整體過程看過一些說明文檔但是具體過程,由於沒有見過實例所以也不是很清楚。希望知道的朋友詳細說說。
下面貼下我的配置,但是這個配置multipart/form-data這塊的表單提交以後
nginx 就會報502錯誤日誌
123.122.113.23 - "POST /gallery2/main.php HTTP/1.1" 502 - /usr/local/www/nginx-dist//50x.html" "GET" "multipart/form-data; boundary=---------------------------1655174106359" "787639" "-"
123.122.113.23 - "POST /gallery2/main.php HTTP/1.1" 405 - /var/www/phpBB//gallery2/main.php" "POST" "multipart/form-data; boundary=---------------------------9374110204596" "787639" "-"
123.122.113.23 - "POST /gallery2/main.php HTTP/1.1" 405 - /var/www/phpBB//gallery2/main.php" "POST" "multipart/form-data; boundary=---------------------------273482319919668" "198779" "-"
123.122.113.23 - "POST /gallery2/main.php HTTP/1.1" 502 - /usr/local/www/nginx-dist//50x.html" "GET" "multipart/form-data; boundary=---------------------------2448482814734" "198673" "-"
下面放我的配置(由於太長只貼比較重要的一部分) server {
        listen       80;
    #    listen       somename:8080;
        server_name  forum.1768.me;
        root        /var/www/phpBB;
        access_log  /var/log/nginx/fastcgi_forum.1768.me.log fastcgi;
        location / {
            root   /var/www/phpBB;
          index  index.php index.htm;
          #fastcgi_pass     localhost:9000;
        #   fastcgi_index       index.php;
        #   fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
        #   include fastcgi_params;
       }
    #   location ~* \.(jpg|png|jpeg|css|js|html)$ {
    #           root /var/www/phpBB;
    #           expires 24h;
    #           }
    #}
#       location .*\/main.php$ {
#           report_uploads proxied;
#       }
        location ~* \.php$ {
            root /var/www/phpBB;
            fastcgi_pass        localhost:9000;
            fastcgi_index       index.php;
            fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
            include fastcgi_params;
            client_max_body_size        8m;
            track_uploads proxied       30s;
            fastcgi_connect_timeout     60;
            fastcgi_send_timeout        180;
            fastcgi_read_timeout        180;
            fastcgi_buffer_size         128k;
            fastcgi_busy_buffers_size   256k;
            fastcgi_pass_header         *;
#           report_uploads proxied;
            }
        location ^~ /progress {
            report_uploads proxied;
                }

[火星人 ] nginx 以fastcgi模式處理php multipart/form-data的問題已經有1173次圍觀

http://coctec.com/docs/service/show-post-16538.html