I am using the latest version of Openresty (1.27.1.1) and I want to handle CONNECT requests. But sending a CONNECT request throws a 405 NOT ALLOWED error. I have tried different lua scripts to try and handle CONNECT requests but my efforts have been to no avail.
I even tried to redirect the 405 error page to a location where I convert the CONNECT request to GET and that works but it closes the connection after getting the response for the GET request (I'm assuming because of the way openresty/nginx handles error page redirections), whereas I want to keep a persistent connection. Forcing keep-alive headers also doesn't work. The code snippet below is the method I'm using right now.
listen 80; error_page 405 = @fix_connect; location / { proxy_pass http://backend_server; } location @fix_connect { access_by_lua_block { ngx.req.set_method(ngx.HTTP_GET) } proxy_pass http://backend_server; } } I'm looking for an alternative method to convert a CONNECT request to GET while maintaining a persistent connection. Thanks