{"id":18457986,"url":"https://github.com/alokkusingh/nginx-layer7-lb","last_synced_at":"2026-01-24T04:03:08.303Z","repository":{"id":95088494,"uuid":"289168653","full_name":"alokkusingh/nginx-layer7-lb","owner":"alokkusingh","description":"Nginx Setup for Layer 7 (Application Layer) Load Balancer with Client Certificate","archived":false,"fork":false,"pushed_at":"2021-08-30T10:51:54.000Z","size":7,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-23T12:18:55.837Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":null,"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/alokkusingh.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-08-21T03:29:48.000Z","updated_at":"2021-08-30T10:51:56.000Z","dependencies_parsed_at":"2023-03-17T04:30:15.355Z","dependency_job_id":null,"html_url":"https://github.com/alokkusingh/nginx-layer7-lb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alokkusingh%2Fnginx-layer7-lb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alokkusingh%2Fnginx-layer7-lb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alokkusingh%2Fnginx-layer7-lb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/alokkusingh%2Fnginx-layer7-lb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/alokkusingh","download_url":"https://codeload.github.com/alokkusingh/nginx-layer7-lb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250430602,"owners_count":21429324,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-06T08:16:20.098Z","updated_at":"2026-01-24T04:03:03.274Z","avatar_url":"https://github.com/alokkusingh.png","language":null,"funding_links":[],"categories":[],"sub_categories":[],"readme":"# nginx-layer7-lb\nNginx Setup for Layer 7 (Application Layer) Load Balancing with Client Certificate\n\n\n## Advantage of using Layer 7 Load Balancer\n- URI/Header/Session based Sticky Session possible\n- SSL Offloading (SSL Termination or SSL Bridging) is done at Load Balancer level to avoid CPU intensive TLS handshaking at Application Level\n- Load Balancer to Backend Server can have longer Keep Alive time to avoid frequent TLS handshake \n\n## Limitations\n- 2 TCP connection - 1 from client to Load Balancer and 1 from Load Balancer to Backend Server\n- No easy way to pass the client certificate to backend server\n\n## Nginx Setup\nPlease refer `nginx.conf` file under `conf` directory.\n\nFew important config sections:\n- Backend Server Configuration - here you have option to add multiple servers (for HA and LB) and load balancing strategy\n  ````\n  upstream x-509-server {\n     server localhost:8443;\n  }\n  ````\n\n- Nginx Server Certificate and Key\n        Signed using Root Certificate (rootCA_Alok.crt) and Root Certificate should be avaiable at Client\n  ````\n  ssl_certificate      /Users/aloksingh/cert/localhost.crt;\n  ssl_certificate_key  /Users/aloksingh/cert/localhost.key;\n  ````\n        \n- client certificate - in case Nginx need to validate Client as well (mutual authentication)\n  ````\n  ssl_verify_client on;\n  ssl_client_certificate /Users/aloksingh/cert/rootCA_Alok.crt;\n  ````\n\n- In case - backend Server need to validate Nginx as well\n    - the below certificate is to validate Ngix by backend\n    - the certificate must be signed with Root Certificate and should be avaiable at backend trust store\n  ````\n  proxy_ssl_certificate     /Users/aloksingh/cert/clientNginx.crt;\n  proxy_ssl_certificate_key /Users/aloksingh/cert/clientNginx.key;\n  proxy_ssl_ciphers         HIGH:!aNULL:!MD5;\n  ````\n\n## Hit the Secure URL\n    curl --cacert rootCA_Alok.crt --key clientAlok.key --cert clientAlok.crt https://localhost:443/api/user\n\n   Where:\n   - `rootCA_Alok.crt` is Load Balancer (Nginx) server Root Certificate\n   - `clientAlok.key` is client private key\n   - `clientAlok.crt` is client certificate\n   - Assuming the `clientAlok.crt` signed using `Root Certificate` (rootCA_Alok.crt). So that Niginx can trust the client certificate.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falokkusingh%2Fnginx-layer7-lb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falokkusingh%2Fnginx-layer7-lb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falokkusingh%2Fnginx-layer7-lb/lists"}