{"id":13776818,"url":"https://github.com/fffonion/lua-resty-sniproxy","last_synced_at":"2026-03-06T21:33:01.479Z","repository":{"id":47700010,"uuid":"60447227","full_name":"fffonion/lua-resty-sniproxy","owner":"fffonion","description":"SNI Proxy based on stream-lua-nginx-module","archived":false,"fork":false,"pushed_at":"2020-08-31T09:39:01.000Z","size":31,"stargazers_count":86,"open_issues_count":2,"forks_count":18,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-12-08T00:00:08.962Z","etag":null,"topics":["ngx-stream-lua","openresty","sniproxy"],"latest_commit_sha":null,"homepage":"https://yooooo.us/2016/lua-resty-sniproxy","language":"Lua","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/fffonion.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-06-05T06:50:44.000Z","updated_at":"2025-10-19T07:10:15.000Z","dependencies_parsed_at":"2022-09-23T17:04:40.021Z","dependency_job_id":null,"html_url":"https://github.com/fffonion/lua-resty-sniproxy","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/fffonion/lua-resty-sniproxy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fffonion%2Flua-resty-sniproxy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fffonion%2Flua-resty-sniproxy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fffonion%2Flua-resty-sniproxy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fffonion%2Flua-resty-sniproxy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/fffonion","download_url":"https://codeload.github.com/fffonion/lua-resty-sniproxy/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/fffonion%2Flua-resty-sniproxy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":30198661,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-06T19:07:06.838Z","status":"ssl_error","status_checked_at":"2026-03-06T18:57:34.882Z","response_time":250,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ngx-stream-lua","openresty","sniproxy"],"created_at":"2024-08-03T18:00:33.503Z","updated_at":"2026-03-06T21:33:01.452Z","avatar_url":"https://github.com/fffonion.png","language":"Lua","funding_links":[],"categories":["Libraries"],"sub_categories":[],"readme":"Name\n====\n\nlua-resty-sniproxy - SNI Proxy based on the ngx_lua cosocket API\n\nTable of Contents\n=================\n\n- [Description](#description)\n- [Status](#status)\n- [Synopsis](#synopsis)\n- [TODO](#todo)\n- [Copyright and License](#copyright-and-license)\n- [See Also](#see-also)\n\n\nDescription\n===========\n\nThis library is an [SNI](https://en.wikipedia.org/wiki/Server_Name_Indication) proxy written in Lua. TLS parsing part is rewritten from [dlundquist/sniproxy](https://github.com/dlundquist/sniproxy)\n\nNote that nginx [stream module](https://nginx.org/en/docs/stream/ngx_stream_core_module.html) and [ngx_stream_lua_module](https://github.com/openresty/stream-lua-nginx-module) is required.\n\nTested on Openresty \u003e= 1.9.15.1.\n\n[Back to TOC](#table-of-contents)\n\nStatus\n========\n\nExperimental.\n\nSynopsis\n========\n\n\n```\nstream {\n    init_by_lua_block {\n        local sni = require(\"resty.sniproxy\")\n        sni.rules = { \n            {\"www.google.com\", \"www.google.com\", 443},\n            {\"www.facebook.com\", \"9.8.7.6\", 443},\n            {\"api.twitter.com\", \"1.2.3.4\"},\n            {\".+.twitter.com\", nil, 443},\n            -- to activate this rule, you must use Lua land proxying\n            -- {\"some.service.svc\", \"unix:/var/run/nginx-proxy-proto.sock\", nil, sni.SNI_PROXY_PROTOCOL_UPSTREAM},\n            -- {\"some2.service.svc\", \"unix:/var/run/nginx-proxy-proto.sock\", nil,\n            --                            sni.SNI_PROXY_PROTOCOL_UPSTREAM + sni.SNI_PROXY_PROTOCOL},\n            {\".\", \"unix:/var/run/nginx-default.sock\"}\n        }   \n    }\n\n    # for OpenResty \u003e= 1.13.6.1, native Nginx proxying\n    lua_add_variable $sniproxy_upstream;\n    server {\n            error_log /var/log/nginx/sniproxy-error.log error;\n            listen 443;\n\n            resolver 8.8.8.8;\n\n            preread_by_lua_block {\n                    local sni = require(\"resty.sniproxy\")\n                    local sp = sni:new()\n                    sp:preread_by()\n            }\n            proxy_pass $sniproxy_upstream;\n    }\n\n    # for OpenResty \u003c 1.13.6.1 or `flags` are configured, Lua land proxying\n    server {\n            error_log /var/log/nginx/sniproxy-error.log error;\n            listen 443;\n\n            resolver 8.8.8.8;\n\n            content_by_lua_block {\n                    local sni = require(\"resty.sniproxy\")\n                    local sp = sni:new()\n                    sp:content_by()\n            }\n    }\n}\n```\n\nA Lua array table `sni_rules` should be defined in the `init_worker_by_lua_block` directive.\n\nThe first value can be either whole host name or regular expression. Use `.` for a default host name. If no entry is matched, connection will be closed.\n\nThe second and third values are target host name and port. A host can be DNS name, IP address or UNIX domain socket path. If host is not defined or set to `nil`, **server_name** in SNI will be used. If the port is not defined or set to `nil` , **443** will be used.\n\nThe forth value is the flags to use. Available flags are:\n\n\n        sni.SNI_PROXY_PROTOCOL -- use client address received from proxy protocol to send to upstream\n        sni.SNI_PROXY_PROTOCOL_UPSTREAM -- send proxy protocol v1 handshake to upstream\n\n\nTo use flags, the server must be configured to do **Lua land proxying** (see above example).\n\n\nRules are applied with the priority as its occurrence sequence in the table. In the example above, **api.twitter.com** will match the third rule **api.twitter.com** rather than the fourth **.+.twitter.com**.\n\nIf the protocol version is less than TLSv1 (eg. SSLv3, SSLv2), connection will be closed, since SNI extension is not supported in these versions.\n\n[Back to TOC](#table-of-contents)\n\n\nTODO\n====\n\n- stress and performance test\n\n[Back to TOC](#table-of-contents)\n\n\nCopyright and License\n=====================\n\nThis module is licensed under the BSD license.\n\nCopyright (C) 2016, by fffonion \u003cfffonion@gmail.com\u003e.\n\nAll rights reserved.\n\nRedistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.\n\n* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.\n\nTHIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n[Back to TOC](#table-of-contents)\n\nSee Also\n========\n* the ngx_stream_lua_module: https://github.com/openresty/stream-lua-nginx-module\n* [dlundquist/sniproxy] (https://github.com/dlundquist/sniproxy)\n* [ngx_stream_ssl_preread_module] (https://nginx.org/en/docs/stream/ngx_stream_ssl_preread_module.html) is available since Nginx 1.11.5 as an alternative to this module.\n\n[Back to TOC](#table-of-contents)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffffonion%2Flua-resty-sniproxy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffffonion%2Flua-resty-sniproxy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffffonion%2Flua-resty-sniproxy/lists"}