[go: nahoru, domu]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Streaming multipart/form-data request body via http v2 not supported yet #166

Open
eleshar opened this issue Jun 18, 2016 · 6 comments
Open
Labels

Comments

@eleshar
Copy link
eleshar commented Jun 18, 2016

Hi,

I'm currently running lua-resty waf on openresty-1.9.15.1 in SIMULATE mode - seeing the following error in my logs (Results in Internal Server Error on front-end).

[error] 16877#0: *1313321 lua entry thread aborted: runtime error: /etc/nginx/lualib/lua-resty-waf/inc/resty/upload.lua:60: http v2 not supported yet
stack traceback:
coroutine 0:
        [C]: in function 'req_socket'
        /etc/nginx/lualib/lua-resty-waf/inc/resty/upload.lua:60: in function 'new'
        /etc/nginx/lualib/lua-resty-waf/lib/request.lua:40: in function 'parse_request_body'
        /etc/nginx/lualib/lua-resty-waf/lib/lookup.lua:23: in function </etc/nginx/lualib/lua-resty-waf/lib/lookup.lua:18>
        /etc/nginx/lualib/lua-resty-waf/waf.lua:419: in function 'exec'
        access_by_lua(lua-waf-body.conf:5):4: in function <access_by_lua(lua-waf-body.conf:5):1>

Any ETA on HTTP/2 support?

@p0pr0ck5
Copy link
Owner

Hi,

This is a limitation of the ngx lua API. See openresty/lua-nginx-module#566 and https://groups.google.com/forum/#!topic/openresty-en/vhHYcoCmRxA. So any ETA is going to be reliant on upstream :)

As a workaround for now you can disable multipart upload parsing: https://github.com/p0pr0ck5/lua-resty-waf#process_multipart_body. Other functionality like query string args, URL-encoded for request bodies, and response data should be unaffected (let me know otherwise if they are).

I'll leave this ticket as a placeholder until http2 support is available via lua-nginx-module, so we don't get the same requests multiple times. Thanks!

@p0pr0ck5
Copy link
Owner

Renaming the title of this issue for clarification.

@p0pr0ck5 p0pr0ck5 changed the title http v2 not supported yet Streaming multipart/form-data request body via http v2 not supported yet Sep 24, 2016
@p0pr0ck5
Copy link
Owner

Noting here for posterity, this links more closely to openresty/lua-resty-upload#24 than other issues note above, as we leverage this library directly.

@chaigon
Copy link
chaigon commented Dec 7, 2016

The issue has been resolved?

@p0pr0ck5
Copy link
Owner
p0pr0ck5 commented Dec 9, 2016

Unless lua-resty-upload has started supporting HTTP/2, then no ;)

@sjnam
Copy link
sjnam commented Oct 18, 2017

I use proxy_pass to use lua-resty-upload in http2. :-)

$ curl -F "file=@sample.txt" https://localhost:8443/upload --http2 --insecure
http {

    server {
        listen        8088;
        location /upload {
            content_by_lua '
                local upload = require "resty.upload"
                local cjson = require "cjson"

                local chunk_size = 5 -- should be set to 4096 or 8192
                                     -- for real-world settings

                local form, err = upload:new(chunk_size)
                if not form then
                    ngx.log(ngx.ERR, "failed to new upload: ", err)
                    ngx.exit(500)
                end

                form:set_timeout(1000) -- 1 sec

                while true do
                    local typ, res, err = form:read()
                    if not typ then
                        ngx.say("failed to read: ", err)
                        return
                    end

                    ngx.say("read: ", cjson.encode({typ, res}))

                    if typ == "eof" then
                        break
                    end
                end

                local typ, res, err = form:read()
                ngx.say("read: ", cjson.encode({typ, res}))
            ';
        }
    }

    server {
        listen          8443 ssl http2 default_server;
        server_name     foo.com;
        ssl_certificate          server.crt;
        ssl_certificate_key  server.key;

        location / {
            proxy_pass               http://backend;
            proxy_request_buffering  off;
            proxy_set_header Host   $host;
            proxy_set_header         X-Real-IP $remote_addr;
            proxy_http_version       1.1;
            proxy_set_header         Connection "";
        }
    }

    upstream backend {
        server localhost:8088;
        keepalive 128;
    }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants