最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

http - How do I convert a CONNECT request to GET in openrestynginx? - Stack Overflow

programmeradmin3浏览0评论

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

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

Share Improve this question asked Feb 17 at 10:31 klaus_03klaus_03 1
Add a comment  | 

1 Answer 1

Reset to default 0

It seems you are looking for ngx_http_proxy_connect_module.

发布评论

评论列表(0)

  1. 暂无评论