尝试上传文件时,连接到上游时connect()失败(111:连接被拒绝)

时间:2019-05-04 15:52:21

标签: nginx nginx-config

我正在尝试使用POST请求将文件上传到我的服务器,并且该文件一直为我提供连接被拒绝的错误。

我已经尝试过使用Google搜索功能,但是我发现的所有信息都无法解决问题。

错误消息:

2019/05/04 15:42:50 [notice] 7033#7033: signal process started
2019/05/04 15:42:59 [error] 7034#7034: *46 connect() failed (111: Connection refused) while connecting to upstream, client: XXX.XXX.XX.XX, server: , request: "POST /upload HTTP/1.1", upstream: "http://127.0.0.1:8080/upload", host: "XX.XX.XXX.XX", referrer: "http://XX.XX.XXX.XX/"

我的.conf文件:

server {
    client_max_body_size 100m;
    listen       80;

    # Upload form should be submitted to this location
    location /upload {
        # Pass altered request body to this location
        upload_pass   @test;

        # Store files to this directory
        # The directory is hashed, subdirectories 0 1 2 3 4 5 6 7 8 9 should exist
        upload_store /usr/share/nginx/html/upload/ 1;

        # Allow uploaded files to be read only by user
        upload_store_access user:rw;

        # Set specified fields in request body
        upload_set_form_field $upload_field_name.name "$upload_file_name";
        upload_set_form_field $upload_field_name.content_type "$upload_content_type";
        upload_set_form_field $upload_field_name.path "$upload_tmp_path";

        # Inform backend about hash and size of a file
        upload_aggregate_form_field "$upload_field_name.md5" "$upload_file_md5";
        upload_aggregate_form_field "$upload_field_name.size" "$upload_file_size";

        upload_pass_form_field "^submit$|^description$";

        upload_cleanup 400 404 499 500-505;
    }

    # Pass altered request body to a backend
    location @test {
        proxy_pass   http://127.0.0.1:8080;
    }
}

我的index.html文件

<html>
  <head>
    <title>Test upload</title>
  </head>
  <body>
    <h2>Select files to upload</h2>
    <form name="upload" method="POST" enctype="multipart/form-data" action="/upload">
      <input type="file" name="file1"><br>
      <input type="submit" name="submit" value="Upload">
      <input type="hidden" name="test" value="value">
    </form>
  </body>
</html>

它应该将文件上传到/ usr / share / nginx / html / upload / 1 / 它只是给我一个502错误的网关,并且没有上传文件。

0 个答案:

没有答案