Daniel15 / simple-nuget-server

A very simple PHP NuGet server
MIT License
116 stars 43 forks source link

Failed to process request. 'ZipArchive::open(): Empty string as source'. The remote server returned an error: (500) ZipArchive::open(): Empty string as source. #39

Open dragan1979 opened 5 years ago

dragan1979 commented 5 years ago

I created issue https://github.com/Daniel15/simple-nuget-server/issues/38, i managed to "partially" solve it (now if i enter wrong API key i'll get error), i added this line in nuget.conf:

fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; under location = /index.php but now getting this, have no any PHP experience so no idea how to troubleshoot it.

 nuget push chocolatey.0.10.11.nupkg -s http://192.168.1.163 -apikey 12345 -verbosity detailed
Pushing chocolatey 0.10.11 to 'http://192.168.1.163'...
PUT http://192.168.1.163/api/v2/package/
System.InvalidOperationException: Failed to process request. 'ZipArchive::open(): Empty string as source'.
The remote server returned an error: (500) ZipArchive::open(): Empty string as source.. ---> System.Net.WebException: The remote server returned an error: (500) ZipArchive::open(): Empty string as source.
  at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00064] in <bd46d4d4f7964dfa9beea098499ab597>:0
  at System.Net.HttpWebRequest.GetResponse () [0x0000e] in <bd46d4d4f7964dfa9beea098499ab597>:0
  at NuGet.RequestHelper.GetResponse () [0x00121] in <e04d0b7bbb524b59b92c15cbbdf5d03e>:0
   --- End of inner exception stack trace ---
  at NuGet.PackageServer.EnsureSuccessfulResponse (NuGet.HttpClient client, System.Nullable`1[T] expectedStatusCode) [0x00189] in <e04d0b7bbb524b59b92c15cbbdf5d03e>:0
  at NuGet.PackageServer.PushPackageToServer (System.String apiKey, System.Func`1[TResult] packageStreamFactory, System.Int64 packageSize, System.Int32 timeout, System.Boolean disableBuffering) [0x0005c] in <e04d0b7bbb524b59b92c15cbbdf5d03e>:0
  at NuGet.PackageServer.PushPackage (System.String apiKey, NuGet.IPackage package, System.Int64 packageSize, System.Int32 timeout, System.Boolean disableBuffering) [0x0002d] in <e04d0b7bbb524b59b92c15cbbdf5d03e>:0
  at NuGet.Commands.PushCommand.PushPackageCore (System.String source, System.String apiKey, NuGet.PackageServer packageServer, System.String packageToPush, System.TimeSpan timeout) [0x00058] in <dc8a236afba24badbb185682f8956bec>:0
  at NuGet.Commands.PushCommand.PushPackage (System.String packagePath, System.String source, System.String apiKey, System.TimeSpan timeout) [0x0003f] in <dc8a236afba24badbb185682f8956bec>:0
  at NuGet.Commands.PushCommand.ExecuteCommand () [0x0008f] in <dc8a236afba24badbb185682f8956bec>:0
  at NuGet.Commands.Command.Execute () [0x000cf] in <dc8a236afba24badbb185682f8956bec>:0
  at NuGet.Program.Main (System.String[] args) [0x0019b] in <dc8a236afba24badbb185682f8956bec>:0

no errors in php7.0-fpm.log and nginx logs

nuget.conf:

# Example of an Nginx configuration for Simple NuGet Server

server {
    server_name 192.168.1.163;
    #client_max_body_size 20M;
    listen 80
    backlog=1024;
    root /opt/simple-nuget-server/public/;
    client_body_buffer_size 5M;
    client_header_buffer_size 4k;
    open_file_cache max=65535 inactive=60s;
    open_file_cache_valid 60s;
    open_file_cache_min_uses 1;
    open_file_cache_errors on;

    rewrite ^/$ /index.php;
    rewrite ^/\$metadata$ /metadata.xml;
    rewrite ^/Search\(\)/\$count$ /count.php;
    rewrite ^/Search\(\)$ /search.php;
    rewrite ^/Packages\(\)$ /search.php;
    rewrite ^/Packages\(Id='([^']+)',Version='([^']+)'\)$ /findByID.php?id=$1&version=$2;
    rewrite ^/GetUpdates\(\)$ /updates.php;
    rewrite ^/FindPackagesById\(\)$ /findByID.php;
    # NuGet.exe sometimes uses two slashes (//download/blah)
    rewrite ^//?download/([^/]+)/([^/]+)$ /download.php?id=$1&version=$2;
    rewrite ^/([^/]+)/([^/]+)$ /delete.php?id=$1&version=$2;

    # NuGet.exe adds /api/v2/ to URL when the server is at the root
    rewrite ^/api/v2/package/$ /index.php;
    rewrite ^/api/v2/package/([^/]+)/([^/]+)$ /delete.php?id=$1&version=$2;

    location ~ \.php$ {

        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_buffers 4 1024k;
        fastcgi_buffer_size 1024k;
        fastcgi_busy_buffers_size 1024k;
        fastcgi_temp_file_write_size 5M;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

    }

    location = /index.php {
        dav_methods PUT DELETE;

        try_files $uri =404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass unix:/var/run/php/php7.2-fpm.sock;
        fastcgi_index index.php;
        fastcgi_buffers 4 1024k;
        fastcgi_buffer_size 1024k;
        fastcgi_busy_buffers_size 1024k;
        fastcgi_temp_file_write_size 5M;
        fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
        include fastcgi_params;

        # PHP doesn't parse request body for PUT requests, so fake a POST.
        fastcgi_param REQUEST_METHOD POST;
        fastcgi_param HTTP_X_METHOD_OVERRIDE $request_method;
    }

    # Used with X-Accel-Redirect
    location /packagefiles {
        internal;
        root /opt/simple-nuget-server/;
    }
}

image