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

lua-nginx-module report http v2 not supported yet unexpectedly #50

Open
ncubrian opened this issue Apr 29, 2019 · 6 comments
Open

lua-nginx-module report http v2 not supported yet unexpectedly #50

ncubrian opened this issue Apr 29, 2019 · 6 comments

Comments

@ncubrian
Copy link

I'm using the following version of Nginx.

nginx version: nginx/1.14.0
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) 
built with OpenSSL 1.0.2k-fips  26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/opt/nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_stub_status_module --with-threads --with-stream --with-stream_ssl_module --add-module=/tmp/ngx_devel_kit-0.3.0 --add-module=/tmp/lua-nginx-module-0.10.9rc7

I have defined four virtual servers in http config block. One virtual server is defined with listen 443 ssl;, while three other virtual servers are defined with listen 443 ssl http2;. The lua-nginx-module is used in the server without http2 configured to handle file upload. The code is as follows.

local req_socket = ngx.req.socket
local sock, err = req_socket()
if not sock then
    return nil, err
end

Strange thing is the error.log reports that http v2 is not supported yet. But the http2 is not even configured in this virtual server. The error log is as below.

2019/04/29 15:26:19 [error] 22281#22281: *6512 lua entry thread aborted: runtime error: /opt/nginx/co
nf/lua/resty/upload.lua:61: http v2 not supported yet
stack traceback:
coroutine 0:
        [C]: in function 'req_socket'
        /opt/nginx/conf/lua/resty/upload.lua:61: in function 'new'

It looks like the http2 configuration exists beyond the virtual server in which it's configured, like somehow it becomes a global thing.
After I delete the http2 in all three other virtual servers, the error.log stops reporting the error mentioned above.
I don't know what make this happen. Is it a bug or something wrong with my configuration?

@misiek08
Copy link

misiek08 commented Apr 29, 2019 via email

@ncubrian
Copy link
Author

conf/nginx.conf

http {
	include            mime.types;
	default_type       application/json;

	log_format         main  '$time_iso8601 $remote_addr $request $host '
		'$status $request_time $bytes_sent $body_bytes_sent '
		'$upstream_addr $upstream_status $upstream_response_time '
		'"$http_user_agent"';

	access_log         logs/access.log  main;

	sendfile           on;
	keepalive_timeout  30;

	gzip               on;
	gzip_min_length    10k;
	gzip_buffers       16	 64k;
	gzip_http_version  1.1;
	gzip_comp_level    3;
	gzip_types         text/plain application/x-javascript text/css application/xml;
	gzip_vary          on;

	proxy_set_header   Host $host;
	proxy_set_header   X-Real-IP $remote_addr;
	proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

	include            *.http.conf;
}

conf/foobar1.http.conf

server {
    listen                          443 ssl;
    server_name                     foobar1.com;
    server_tokens                   off;

    ssl_certificate                 foobar.com.crt;
    ssl_certificate_key             foobar.com.key;

    ssl_ciphers                     EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers       on;

    ssl_protocols                   TLSv1.1 TLSv1.2;

    ssl_session_cache               shared:SSL:10m;
    ssl_session_timeout             60m;

    ssl_stapling                    on;
    ssl_stapling_verify             on;
    ssl_trusted_certificate         Intermediate_Certificate.pem;
    resolver                        8.8.8.8 8.8.4.4 114.114.114.114 valid=300s;
    resolver_timeout                5s;

    default_type                    application/octet-stream;

    access_log                      logs/foobar1.log  main;

    if ($request_method !~ ^(GET|HEAD|POST|OPTIONS|DELETE|PUT)$ ) {
        return                      444;
    }

    include upload.conf;
}

conf/foobar2.http.conf

server {
    listen                          443 ssl http2;
    server_name                     foobar2.com;
    server_tokens                   off;

    ssl_certificate                 foobar.com.crt;
    ssl_certificate_key             foobar.com.key;

    ssl_ciphers                     EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5;
    ssl_prefer_server_ciphers       on;

    ssl_protocols                   TLSv1.1 TLSv1.2;

    ssl_session_cache               shared:SSL:10m;
    ssl_session_timeout             60m;

    ssl_stapling                    on;
    ssl_stapling_verify             on;
    ssl_trusted_certificate         Intermediate_Certificate.pem;
    resolver                        8.8.8.8 8.8.4.4 114.114.114.114 valid=300s;
    resolver_timeout                5s;


    access_log                      logs/foobar2.log  main;

    if ($request_method !~ ^(GET|HEAD|POST|OPTIONS|DELETE|PUT)$ ) {
        return                      444;
    }

    location / {
        alias                       /opt/foobar2/;
        index                       index.html;
    }
}

conf/upload.conf

location /upload {
	auth_request					/auth/upload.json;
    client_body_buffer_size         10m;
	client_max_body_size 			20m;
	content_by_lua_file 			'conf/lua/upload.lua';
}

conf/lua/upload.lua

package.path = '/usr/local/share/lua/5.1/?.lua;/opt/nginx/conf/lua/resty/?.lua;'
package.cpath = '/usr/local/lib/lua/5.1/?.so;'

if ngx.var.request_method == "GET" then
	ngx.log(ngx.ERR, "upload does not allow GET method")
	ngx.exit(412)
end

local upload = require "upload"

local chunk_size = 4096
local form = upload:new(chunk_size)

conf/lua/resty/upload.lua

local req_socket = ngx.req.socket
function _M.new(self, chunk_size)
    local boundary = get_boundary()

    if not boundary then
        return nil, "no boundary defined in Content-Type"
    end

    local sock, err = req_socket()
    if not sock then
        return nil, err
    end
end

When I tried to upload a file through https://foobar1.com/upload, the error happened.

Show your simplified configuration, please. pon., 29.04.2019, 14:35 użytkownik ncubrian [email protected] napisał:

I'm using the following version of Nginx. nginx version: nginx/1.14.0 built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC) built with OpenSSL 1.0.2k-fips 26 Jan 2017 TLS SNI support enabled configure arguments: --prefix=/opt/nginx --with-http_ssl_module --with-http_v2_module --with-http_realip_module --with-http_gunzip_module --with-http_gzip_static_module --with-http_auth_request_module --with-http_stub_status_module --with-threads --with-stream --with-stream_ssl_module --add-module=/tmp/ngx_devel_kit-0.3.0 --add-module=/tmp/lua-nginx-module-0.10.9rc7 I have defined four virtual servers in http config block. One virtual server is defined with listen 443 ssl;, while three other virtual servers are defined with listen 443 ssl http2;. The lua-nginx-module is used in the server without http2 configured to handle file upload. The code is as follows. local req_socket = ngx.req.socket local sock, err = req_socket() if not sock then return nil, err end Strange thing is the error.log reports that http v2 is not supported yet. But the http2 is not even configured in this virtual server. The error log is as below. 2019/04/29 15:26:19 [error] 22281#22281: *6512 lua entry thread aborted: runtime error: /opt/nginx/co nf/lua/resty/upload.lua:61: http v2 not supported yet stack traceback: coroutine 0: [C]: in function 'req_socket' /opt/nginx/conf/lua/resty/upload.lua:61: in function 'new' It looks like the http2 configuration exists beyond the virtual server in which it's configured, like somehow it becomes a global thing. After I delete the http2 in all three other virtual servers, the error.log stops reporting the error mentioned above. I don't know what make this happen. Is it a bug or something wrong with my configuration? — You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub <#50>, or mute the thread https://github.com/notifications/unsubscribe-auth/AADOT5VC67HIYQBLJXMN6TTPS3TP3ANCNFSM4HJC4ZWA .

@ncubrian
Copy link
Author

ncubrian commented May 5, 2019

Show your simplified configuration, please. pon., 29.04.2019, 14:35 użytkownik ncubrian [email protected] napisał:

Hello friend, do you have any clues?

@ilya-merkushin
Copy link

I have the same problem too. It don't work when I upload by browser, but it work when I upload by Postman. Removing http2 from all configs can fix this problem, but it's not a good way(

@ddnomad
Copy link

ddnomad commented Jul 25, 2019

Got the same error message :|

@joelchornik
Copy link

Same over here with openresty/1.15.8.1

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

No branches or pull requests

5 participants