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

HTTP2 support #566

Closed
alubbe opened this issue Sep 11, 2015 · 30 comments
Closed

HTTP2 support #566

alubbe opened this issue Sep 11, 2015 · 30 comments

Comments

@alubbe
Copy link
Contributor

alubbe commented Sep 11, 2015

With nginx support for HTTP2 on the horizon, what's the plan of supporting it?
Is it likely that everything that works for SPDY will continue to work?
Is there any chance we could also get ngx.location.capture to work? That would be super helpful 👍

@agentzh
Copy link
Member

agentzh commented Sep 13, 2015

@alubbe I haven't tried the new http2 patch for nginx myself. My hunch is that this should be as transparent as the former SPDY mode. You're welcome to try it out on your side and report back any findings (or even fixes!) :) Thanks!

@alubbe
Copy link
Contributor Author

alubbe commented Sep 13, 2015

Yes, it's quite similar to SPDY. What was the reason location capture doesn't work right now? Is it a fundamental problem?

@agentzh
Copy link
Member

agentzh commented Sep 14, 2015

@alubbe There's been reports from the community that ngx.location.capture does work with the latest SPDY impl in nginx. I just haven't had the chance to confirm myself and update the docs. As always, you're recommended to try it out yourself.

@alubbe
Copy link
Contributor Author

alubbe commented Sep 19, 2015

I can confirm that it does work with SPDY 👍
I will keep this ticket open until http2 hits an official open source nginx release and will report back.

@agentzh
Copy link
Member

agentzh commented Sep 19, 2015

@alubbe Good to know that. Then we can remove the alert regarding ngx.location.capture* + SPDY in ngx_lua's manual.

Thanks for your feedback.

@alexander-stepanov
Copy link

I have tried using OpenResty-1.9.3.1 with SPDY (3.1) module enabled and noticed that ngx.location.capture* works well for (internal) locations with local files but hangs for locations that have proxy_pass mode.

@splitice
Copy link

I cant remember if I posted this. After the first reports of SPDY + location.capture working I tried it.

At first it did work (proxy_pass to remote server + location.capture and ngx.print) in the testing environment, then we moved the code to a staging environment and the production code / configuration - it didnt work. I didnt have time either to find the problem though.

@splitice
Copy link

There is also one other method that doesnt work ngx.req.get_headers(true). Segfaults on a SPDY listener.

@fasterthanlime
Copy link

I will keep this ticket open until http2 hits an official open source nginx release and will report back.

I think nginx 1.9.5 might fit that description? https://www.nginx.com/blog/nginx-1-9-5/

@defanator
Copy link
Contributor

I was able to get epoll_ctl() alert resulting in 500 from subrequest issued with ngx.location.capture - only for HTTP/2.0 request (HTTP/1.x works just fine with the same configuration). Here's the debug log and config snippet: https://gist.github.com/defanator/b36d776935fbfdfa8b07

This was nginx/1.9.6 with lua-nginx-module 0.9.16.

@agentzh
Copy link
Member

agentzh commented Nov 5, 2015

@defanator Thanks for the info. I'll have a look when I have a chance.

@defanator
Copy link
Contributor

@agentzh I made the same tests with 0.9.17 + nginx'es 1.8.0/1.9.4 (spdy) and 1.9.6 (http2) and it works just fine - so I think there is no need to check the log from 0.9.16. The following commit seems to be the cure: 8b32f36 - thanks!

@agentzh
Copy link
Member

agentzh commented Nov 15, 2015

@defanator Good to know. Thanks for the feedback!

alexanderguy pushed a commit to lightcrest/nginx that referenced this issue Nov 20, 2015
@jmealo
Copy link

jmealo commented Dec 12, 2015

@agentzh I have experienced crippling memory leaks when using HTTP/2 and Lua. Disabling HTTP/2 seems to have fixed the issue without any other configuration changes. When the memory leaks it's not traceable using any user land tools. I initially blamed the only other piece of software running on my frontends which is consul from hashicorp, however, after working with them on consul issue #1476 and disabling HTTP/2 that seems unlikely.

I have the output of the following commands on here:

  • free -tm
  • cat /proc/meminfo
  • slabtop -o
  • vmstat, ps -eo vsz,rss,comm | grep nginx

I don't mean to hijack this issue, I just want to know what additional information I can provide and provide some warning that under production load HTTP/2 itself works great, but seems to be dangerous to use in combination with Lua.

@agentzh
Copy link
Member

agentzh commented Dec 13, 2015

@jmealo The ngx_lua module has never been officially tested with HTTP/2. It would be great if you can create a minimized and isolated test case that I can run locally to reproduce the problem.

@leebenson
Copy link

any updates to this?

@agentzh
Copy link
Member

agentzh commented Jan 27, 2016

@leebenson There's no activity on our side since we've been very busy with other things (ngx_stream_lua_module and etc). I'd like to rely on community contributions here. Patches welcome and volunteers welcome :)

@jmealo
Copy link

jmealo commented Jan 27, 2016

@leebenson @agentzh I am using openresty/1.9.7.1 and the lua-nginx module with HTTP/2 in production with no issues. (The issue I had was unrelated.)

I'm running Ubuntu 14.04 x64 (3.13.0-68-generic).

I use the following directives:

access_by_lua
access_by_lua_file
rewrite_by_lua
rewrite_by_lua_file
content_by_lua
content_by_lua_file

I use the following OpenResty provided modules:

"cjson"
"resty.mysql"

I use the following third-party modules:

"resty.cookie" -- (from Cloud Flare)
"resty.random" -- (the fork with UUID generation)
"router"       -- (router.lua v2.1.0)

I use ngx.shared ngx.exec and ngx.say as well if that helps anyone.

@misiek08
Copy link

@jmealo can you tell as what was causing your issue? I have some problems while testing lua and http2, but I use proxy_pass, rewrite's and try_files to make complex system for live streaming platform.
I don't know it's lua problem or I did some mistakes.

@jmealo
Copy link

jmealo commented Apr 21, 2016

@misiek08 I have no issues functionality-wise but when I run OpenResty and consul together on Ubuntu 14.04 there is a kernel memory leak that cannot be reproduced by running either component in isolation.

I've been running in productions since November without issues since I removed consul in December. My load balancers have been up the past 68 days (rebooted for upgrade) and average 3-5k connections (HTTP/2, web socket, always-open) without issues.

Learning to write memory efficient Lua:
I'm not sure what your Lua background is; but I found it helpful to program Lua on an ESP8266 Wifi chip as it's quite memory constrained.

Debugging lua running in NGINX:
http://notebook.kulchenko.com/zerobrane/debugging-openresty-nginx-lua-scripts-with-zerobrane-studio
(I have not used it personally, but, this may be promising)

Getting help:
@misiek08 perhaps you should post a gist with your files/configuration and open an issue or e-mail the mailing list? HTTP/2 and SPDY support are young so it's not entirely possible that you've hit an edge case.

Recommended reading:
I found it helpful to learn the NGINX internals and request lifecycle before getting too far in OpenResty.

Good luck!

@misiek08
Copy link

misiek08 commented Apr 21, 2016 via email

@agentzh
Copy link
Member

agentzh commented Apr 26, 2016

@misiek08 Yeah, nginx C programming is hard. Better stick with OpenResty's own C modules whenever possible :)

@misiek08
Copy link

misiek08 commented Apr 26, 2016 via email

@mushiwords
Copy link

what lua or luaJit version should I select when using http v2, thanks!

@agentzh
Copy link
Member

agentzh commented Jul 27, 2016

@yaung LuaJIT 2.1 is recommended. It's more recommended to use the OpenResty bundle directly to avoid troubles, especially compatibility issues and building troubles:

https://openresty.org/en/

@mushiwords
Copy link

Does the latest version of lua_nginx_module support http2 ?

@agentzh
Copy link
Member

agentzh commented Aug 18, 2016

@yaung To some extend, yes.

@agentzh agentzh closed this as completed Aug 18, 2016
@adrhc
Copy link

adrhc commented Jan 16, 2019

There are still problems, see #724

@agentzh
Copy link
Member

agentzh commented Feb 4, 2019

Yeah, certain features are still problematic in HTTP/2. We'll work on them.

@ossmonger
Copy link

With regards to a comment on "ngx.location.capture - only for HTTP/2.0 not working", is this fixed by any chance now ?
If not, is there any other way I can fire sub-request using Lua in Nginx ? http2 is a must-have requirement for me.

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