{"id":22275857,"url":"https://github.com/zigzagak/ngx_http_response_body_module","last_synced_at":"2025-07-06T17:32:37.865Z","repository":{"id":148036409,"uuid":"88207595","full_name":"ZigzagAK/ngx_http_response_body_module","owner":"ZigzagAK","description":"Capture response body into nginx variable","archived":false,"fork":false,"pushed_at":"2025-02-12T10:08:46.000Z","size":30,"stargazers_count":12,"open_issues_count":3,"forks_count":8,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-04-05T00:51:12.214Z","etag":null,"topics":["nginx","nginx-log","nginx-response-body"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ZigzagAK.png","metadata":{"files":{"readme":"README.markdown","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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":"2017-04-13T21:21:52.000Z","updated_at":"2025-02-15T20:03:55.000Z","dependencies_parsed_at":"2023-03-30T11:35:31.467Z","dependency_job_id":null,"html_url":"https://github.com/ZigzagAK/ngx_http_response_body_module","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ZigzagAK/ngx_http_response_body_module","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZigzagAK%2Fngx_http_response_body_module","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZigzagAK%2Fngx_http_response_body_module/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZigzagAK%2Fngx_http_response_body_module/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZigzagAK%2Fngx_http_response_body_module/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ZigzagAK","download_url":"https://codeload.github.com/ZigzagAK/ngx_http_response_body_module/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ZigzagAK%2Fngx_http_response_body_module/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263942337,"owners_count":23533362,"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":["nginx","nginx-log","nginx-response-body"],"created_at":"2024-12-03T14:12:38.970Z","updated_at":"2025-07-06T17:32:37.860Z","avatar_url":"https://github.com/ZigzagAK.png","language":"C","funding_links":[],"categories":[],"sub_categories":[],"readme":"Name\n====\n\nngx_http_response_body_module - extract body response into variable.\n\nTable of Contents\n=================\n\n* [Name](#name)\n* [Status](#status)\n* [Synopsis](#synopsis)\n* [Description](#description)\n* [Configuration directives](#configuration-directives)\n\nStatus\n======\n\nThis library is production ready.\n\nDescription\n===========\n\nCapture response body into nginx $response_body variable.\n\n[Back to TOC](#table-of-contents)\n\nSynopsis\n========\n\n```nginx\nhttp {\n    include       mime.types;\n    default_type  application/octet-stream;\n\n    log_format  main  '$remote_addr - $remote_user [$time_local] \"$request\" $status \"$err\" \"$response_body\"';\n    log_format  test  '$remote_addr - $remote_user [$time_local] \"$request\" $status \"$err\" \"$test_response_body\"';\n\n\n    access_log  logs/access.log  main;\n\n    upstream test {\n        server 127.0.0.1:7777;\n    }\n\n    map $status $cond {\n      500       1;\n      401       1;\n      403       1;\n      404       1;\n      default   0;\n    }\n\n    capture_response_body                   off;\n    capture_response_body_buffer_size       1m;\n    capture_response_body_buffer_size_min   4k;\n    capture_response_body_buffer_size_multiplier   2;\n    capture_response_body_if                $cond 1;\n    capture_response_body_if_latency_more   1s;\n\n    map $response_body $err {\n      ~\\\"error\\\":\\\"(?\u003ce\u003e.+)\\\" $e;\n      default \"\";\n    }\n\n    server {\n        listen 7777;\n        location / {\n            echo_sleep 1.5;\n            echo '0000000000';\n        }\n        location /500 {\n            echo_status 500;\n            echo '{\"error\":\"internal error\"}';\n        }\n        location /200 {\n            echo OK;\n        }\n        location /404 {\n            echo_status 404;\n            echo '404';\n        }\n        location /header_in {\n            echo 'OK';\n        }\n        location /header_out {\n            add_header X-Trace-Response 1;\n            echo 'OK';\n        }\n        location /test {\n            add_header X-Trace-Response 1;\n            echo 'OK';\n        }\n    }\n\n    server {\n        capture_response_body on;\n        listen 8888;\n        location / {\n            proxy_pass http://test;\n        }\n        location /header_in {\n            capture_response_body_if $http_x_trace *;\n            proxy_pass http://test;\n        }\n        location /header_out {\n            capture_response_body_if $sent_http_x_trace_response *;\n            proxy_pass http://test;\n        }\n        location /test {\n            access_log  logs/test.log  test;\n            capture_response_body_var test_response_body;\n            capture_response_body_if $sent_http_x_trace_response 1;\n            proxy_pass http://test;\n        }\n    }\n}\n```\n\n[Back to TOC](#table-of-contents)\n\nConfiguration directives\n========================\n\ncapture_response_body\n--------------\n* **syntax**: `capture_response_body on|off`\n* **default**: `off`\n* **context**: `http,server,location`\n\nTurn on response body capture.\n\ncapture_response_body_var\n--------------\n* **syntax**: `capture_response_body_var \u003cname\u003e`\n* **default**: `response_body`\n* **context**: `http,server,location`\n\nVariable name.\n\ncapture_response_body_buffer_size\n--------------\n* **syntax**: `capture_response_body_buffer_size \u003csize\u003e`\n* **default**: `pagesize`\n* **context**: `http,server,location`\n\nMaximum buffer size.\n\ncapture_response_body_buffer_size_min\n--------------\n* **syntax**: `capture_response_body_buffer_size_min \u003csize\u003e`\n* **default**: `pagesize`\n* **context**: `http,server,location`\n\nMinimum amount of memory allocated for chunked response.\n\ncapture_response_body_buffer_size_multiplier\n--------------\n* **syntax**: `capture_response_body_buffer_size_multiplier \u003cn\u003e`\n* **default**: `2`\n* **context**: `http,server,location`\n\nReallocation multiplier.\n\ncapture_response_body_if\n--------------\n* **syntax**: `capture_response_body_if \u003ccomplex variable\u003e \u003cvalue\u003e`\n* **default**: `none`\n* **context**: `http,server,location`\n\nCapture response body if result of calculation \u003ccomplex variable\u003e is equal \u003cvalue\u003e.  \n\u003cvalue\u003e may be empty string or special '*'.\n\ncapture_response_body_if_1xx\n--------------\n* **syntax**: `capture_response_body_if_1xx on`\n* **default**: `off`\n* **context**: `http,server,location`\n\nCapture response body for http statuses 1xx.\n\ncapture_response_body_if_2xx\n--------------\n* **syntax**: `capture_response_body_if_2xx on`\n* **default**: `off`\n* **context**: `http,server,location`\n\nCapture response body for http statuses 2xx.\n\ncapture_response_body_if_3xx\n--------------\n* **syntax**: `capture_response_body_if_3xx on`\n* **default**: `off`\n* **context**: `http,server,location`\n\nCapture response body for http statuses 3xx.\n\ncapture_response_body_if_4xx\n--------------\n* **syntax**: `capture_response_body_if_4xx on`\n* **default**: `off`\n* **context**: `http,server,location`\n\nCapture response body for http statuses 4xx.\n\ncapture_response_body_if_5xx\n--------------\n* **syntax**: `capture_response_body_if_5xx on`\n* **default**: `off`\n* **context**: `http,server,location`\n\nCapture response body for http statuses 5xx.\n\ncapture_response_body_if_latency_more\n--------------\n* **syntax**: `capture_response_body_if_latency_more \u003csec\u003e`\n* **default**: `none`\n* **context**: `http,server,location`\n\nCapture response body only if request time is greather than specified in the parameter.\n\n[Back to TOC](#table-of-contents)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzigzagak%2Fngx_http_response_body_module","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzigzagak%2Fngx_http_response_body_module","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzigzagak%2Fngx_http_response_body_module/lists"}