Daniel15 / simple-nuget-server

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

nuget push replies Failed to process request. 'No package file' #14

Open androidLaLa opened 8 years ago

androidLaLa commented 8 years ago

public/push.php file did not receive $_FILES['package'] => array(0){}

I've installed on my server.

and setting up nginx.conf file like

server{
    ....
}
server{
    ....
}
....
server {
    server_name nuget.myservername.com;

    set $documentRoot /home/web-release/nuget/simple-nuget-server/public;
    root $documentRoot;

    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$ {
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;
        fastcgi_param SCRIPT_FILENAME $documentRoot/$fastcgi_script_name;
    }

    location = /index.php {
        dav_methods put delete;
        include fastcgi_params;
        fastcgi_pass 127.0.0.1:9000;

        # 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;
        fastcgi_param SCRIPT_FILENAME $documentRoot/$fastcgi_script_name;
    }

    # used with x-accel-redirect
    location /packagefiles {
        internal;
        root /home/web-release/nuget/simple-nuget-server/public/;
    }
}

is it wrong configuration?

"fastcgi_pass php" to error on my server like this

nginx: [emerg] no port in upstream "php" in /etc/nginx/conf.d/vhost.conf:84
nginx: configuration file /etc/nginx/nginx.conf test failed

so

I've edited "fastcgi_pass php" to "fastcgi_pass 127.0.0.1:9000" also added fastcgi_param SCRIPT_FILENAME $documentRoot/$fastcgi_script_name;

any solution?

btoda commented 7 years ago

It might be an issue with the nuget I guess.. I have the same issue... and i checked the $_Files object and it is completely empty. ( I am using apache to host)

roman-miniailov commented 7 years ago

Resolved using this Nginx config:

Example of an Nginx configuration for Simple NuGet Server
server {
    listen 80 default_server;
    listen [::]:80 default_server;

    server_name _;
    root /var/www/html/simple-nuget-server/public/;

    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$ {
    #   include fastcgi_params;
    #   fastcgi_pass php;
    #}

    #location = /index.php {
    #   dav_methods PUT DELETE;
    #   include fastcgi_params;
    #   fastcgi_pass php;

    #   # 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;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000

    location ~ \.php$ {
        dav_methods PUT DELETE;
        include snippets/fastcgi-php.conf;
        include fastcgi_params;

        # With php7.0-cgi alone:
        #fastcgi_pass 127.0.0.1:9000;
        #fastcgi_param REQUEST_METHOD POST;
        #fastcgi_param HTTP_X_METHOD_OVERRIDE $request_method;

        # With php7.0-fpm:
        fastcgi_pass unix:/run/php/php7.0-fpm.sock;
        fastcgi_param REQUEST_METHOD POST;
        fastcgi_param HTTP_X_METHOD_OVERRIDE $request_method;

        #fastcgi_index index.php;
    }

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

    index index.html index.htm index.nginx-debian.html index.php;
}