{"id":15043862,"url":"https://github.com/alexandergrooff/nginx-static-analysis","last_synced_at":"2025-07-16T09:40:13.804Z","repository":{"id":62058816,"uuid":"440884659","full_name":"AlexanderGrooff/nginx-static-analysis","owner":"AlexanderGrooff","description":"Parse Nginx configurations in a clear manner for debugging purposes","archived":false,"fork":false,"pushed_at":"2024-07-15T19:41:26.000Z","size":135,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-15T00:33:28.092Z","etag":null,"topics":["nginx","static-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AlexanderGrooff.png","metadata":{"files":{"readme":"README.md","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":"2021-12-22T14:28:08.000Z","updated_at":"2025-01-22T07:18:01.000Z","dependencies_parsed_at":"2024-04-25T07:27:20.502Z","dependency_job_id":"cd6fed31-1c3b-4707-93c2-876e9b37b37b","html_url":"https://github.com/AlexanderGrooff/nginx-static-analysis","commit_stats":{"total_commits":106,"total_committers":1,"mean_commits":106.0,"dds":0.0,"last_synced_commit":"f862fa1bd269f27d3dcd41740d2b62cc67aeb344"},"previous_names":[],"tags_count":20,"template":false,"template_full_name":null,"purl":"pkg:github/AlexanderGrooff/nginx-static-analysis","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderGrooff%2Fnginx-static-analysis","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderGrooff%2Fnginx-static-analysis/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderGrooff%2Fnginx-static-analysis/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderGrooff%2Fnginx-static-analysis/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AlexanderGrooff","download_url":"https://codeload.github.com/AlexanderGrooff/nginx-static-analysis/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AlexanderGrooff%2Fnginx-static-analysis/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265500606,"owners_count":23777518,"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","static-analysis"],"created_at":"2024-09-24T20:49:43.419Z","updated_at":"2025-07-16T09:40:13.779Z","avatar_url":"https://github.com/AlexanderGrooff.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nginx Static Analysis\n\n[![nginx-static-analysis](https://img.shields.io/pypi/v/nginx-static-analysis)](https://pypi.org/project/nginx-static-analysis/)\n\nParse Nginx configurations on your host and filter for directives/values.\n\nLargely powered by [Crossplane](https://github.com/nginxinc/crossplane).\n\n## Installation\n\nYou're able to find the `nginx-static-analysis` binary in the following places:\n\n```bash\n\n# Pip\npip install nginx-static-analysis\n\n# Arch\nyay -S nginx-static-analysis-git\n```\n\n## Analysing your Nginx configuration\n\nYou can list any directive within your Nginx configuration. For example, show all `listen` directives:\n```\napp@wifbtb-testalex-magweb-cmbl:~$ nginx-static-analysis -d listen\n+-------------------------------------------------+--------------------+-------------------------------------+\n|                       File                      |       Values       |              Directives             |\n+-------------------------------------------------+--------------------+-------------------------------------+\n|      /etc/nginx/servers/example.com.conf:3      |         80         | http -\u003e include -\u003e server -\u003e listen |\n|      /etc/nginx/servers/example.com.conf:4      |        443         | http -\u003e include -\u003e server -\u003e listen |\n|      /etc/nginx/servers/example.com.conf:5      |        8080        | http -\u003e include -\u003e server -\u003e listen |\n|      /etc/nginx/servers/example.com.conf:6      |        8888        | http -\u003e include -\u003e server -\u003e listen |\n| /etc/nginx/servers/testalex.hypernode.io.conf:3 | 80 default_server  | http -\u003e include -\u003e server -\u003e listen |\n| /etc/nginx/servers/testalex.hypernode.io.conf:4 | 443 default_server | http -\u003e include -\u003e server -\u003e listen |\n+-------------------------------------------------+--------------------+-------------------------------------+\n```\n\nFiltering also works for values, like showing all `location` blocks with value `/`.\nThis shows you the tree leading up to the filtered values, and all children under the filter:\n```\napp@wifbtb-testalex-magweb-cmbl:~$ nginx-static-analysis -f location=/\n+-------------------------------------------------+-----------------------+-----------------------------------------------------+\n|                       File                      |         Values        |                      Directives                     |\n+-------------------------------------------------+-----------------------+-----------------------------------------------------+\n|             /etc/nginx/nginx.conf:10            |                       |                         http                        |\n|             /etc/nginx/nginx.conf:87            |  /etc/nginx/servers/* |                   http -\u003e include                   |\n|      /etc/nginx/servers/example.com.conf:1      |                       |              http -\u003e include -\u003e server              |\n|      /etc/nginx/servers/example.com.conf:8      |           /           |        http -\u003e include -\u003e server -\u003e location        |\n|      /etc/nginx/servers/example.com.conf:9      | http://localhost:8003 | http -\u003e include -\u003e server -\u003e location -\u003e proxy_pass |\n| /etc/nginx/servers/testalex.hypernode.io.conf:1 |                       |              http -\u003e include -\u003e server              |\n| /etc/nginx/servers/testalex.hypernode.io.conf:6 |           /           |        http -\u003e include -\u003e server -\u003e location        |\n| /etc/nginx/servers/testalex.hypernode.io.conf:7 |          403          |   http -\u003e include -\u003e server -\u003e location -\u003e return   |\n+-------------------------------------------------+-----------------------+-----------------------------------------------------+\n```\n\nIf you only want to show the filtered values, or any children under the filtered values, simply specify that\nyou want to show that directive:\n```\napp@wifbtb-testalex-magweb-cmbl:~$ nginx-static-analysis -f location=/ -d return -d location\n+--------------------------------------------------+---------+-------------------------------------------------+\n|                       File                       |  Values |                    Directives                   |\n+--------------------------------------------------+---------+-------------------------------------------------+\n| /etc/nginx/servers/testalex.hypernode.io.conf:6  |    /    |      http -\u003e include -\u003e server -\u003e location      |\n| /etc/nginx/servers/testalex.hypernode.io.conf:7  |   403   | http -\u003e include -\u003e server -\u003e location -\u003e return |\n| /etc/nginx/servers/testalex.hypernode.io.conf:10 | /banaan |      http -\u003e include -\u003e server -\u003e location      |\n| /etc/nginx/servers/testalex.hypernode.io.conf:11 |   404   | http -\u003e include -\u003e server -\u003e location -\u003e return |\n|      /etc/nginx/servers/example.com.conf:8       |    /    |      http -\u003e include -\u003e server -\u003e location      |\n+--------------------------------------------------+---------+-------------------------------------------------+\n```\n\nBy default it parses `/etc/nginx/nginx.conf` and all includes, but you can specify the starting file:\n```\napp@wifbtb-testalex-magweb-cmbl:~$ nginx-static-analysis -f /some/other/nginx.conf -d location\n...\n```\n\n## Feeding logs into the analysis\n\nYou can feed access/error logs into the analysis by piping it into stdin:\n```\napp@wifbtb-testalex-magweb-cmbl:~$ tail /var/log/nginx/access.log -n1 | nginx-static-analysis d location\n+----------------------------------------------------+--------+------------------------------------------+\n|                        File                        | Values |                Directives                |\n+----------------------------------------------------+--------+------------------------------------------+\n|            /etc/nginx/testsite.conf:18             |   /    |  http -\u003e include -\u003e server -\u003e location   |\n| /etc/nginx/sites/http.testalex.hypernode.io.conf:8 |   /    |            server -\u003e location            |\n|            /etc/nginx/magento2.conf:17             |   /    | server -\u003e include -\u003e include -\u003e location |\n+----------------------------------------------------+--------+------------------------------------------+\n```\n\nThe analysis creates filters based on the incoming loglines. Those filters are combined with the arguments given\nto the `nginx-static-analysis` command.\n\n## Development\n\nThis package is using Python \u003e=3.7. Simply `pip install -r requirements/base.txt` into your local venv to install the dependencies.\n\n### Testing\n\nThis package uses `pytest` for testing. You can run the tests with `pytest`, which will invoke an Nginx container with some sample configs.\nIf not present, it'll be built automatically.\n\n### Build\n\nThis package can be build locally:\n\n```bash\n# Arch\npip install -r requirements/development.txt\nmakepkg -sCf  # Include -i to install the package locally\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandergrooff%2Fnginx-static-analysis","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Falexandergrooff%2Fnginx-static-analysis","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Falexandergrooff%2Fnginx-static-analysis/lists"}