pgaertig / nginx-big-upload

Resumable and reliable file uploads of any size. Nginx extension written in Lua.
https://github.com/pgaertig/nginx-big-upload
Other
192 stars 49 forks source link

How to use 'auth_request' directive with this module? #21

Closed snaffi closed 7 years ago

snaffi commented 7 years ago

I can not use auth_request. Nginx proxy body to my backend on / upload, instead of performing sub request on / api / v1 / check_auth. Can you help me? @pgaertig

location = /upload {
        auth_request    /api/v1/check_auth;
        uwsgi_pass_request_body off;
        uwsgi_pass      uwsgi://api:8001;

        set $storage backend_file;
        set $file_storage_path /var/www/data;
        set $backend_url /api/v1/upload_finish;

        set $bu_sha1 on;
        set $bu_checksum on;

        set $package_path '/etc/nginx/?.lua';
        content_by_lua_file /etc/nginx/big-upload.lua;
    }
pgaertig commented 7 years ago

I think you should remove uwsgi_pass from this location, because it may override content_by_lua_file handler. I guess you want that api backend in location /api. Please reopen if you still have the issue with auth_request.

snaffi commented 7 years ago

I use access_by_lua directive.

access_by_lua '
             local res = ngx.location.capture("/api/v1/auth/check_auth")

             if res.status == ngx.HTTP_OK then
                 return
             end
             ngx.exit(res.status)
         ';

Thank you for response.