Parse Nginx configurations in a clear manner for debugging purposes
Project description
Nginx Static Analysis
Parse Nginx configurations on your host and filter for directives/values.
Largely powered by Crossplane.
Analysing your Nginx configuration
You can list any directive within your Nginx configuration. For example, show all listen
directives:
app@wifbtb-testalex-magweb-cmbl:~$ nginx-static-analysis directive listen
+------------------------------------------------------+----------------------------------------+------------------+
| File | Values | Directives |
+------------------------------------------------------+----------------------------------------+------------------+
| /etc/nginx/sites/http.testalex.hypernode.io.conf:4 | 127.0.0.1:1337 default_server | server -> listen |
| /etc/nginx/sites/http.testalex.hypernode.io.conf:16 | 8888 default_server | server -> listen |
| /etc/nginx/sites/https.testalex.hypernode.io.conf:6 | 127.0.0.1:443 ssl http2 default_server | server -> listen |
| /etc/nginx/sites/https.testalex.hypernode.io.conf:22 | 8443 ssl http2 default_server | server -> listen |
+------------------------------------------------------+----------------------------------------+------------------+
Filtering also works for values, like showing all location
blocks with value /
:
app@wifbtb-testalex-magweb-cmbl:~$ nginx-static-analysis directive location --values /
+----------------------------------------------------+--------+------------------------------------------+
| File | Values | Directives |
+----------------------------------------------------+--------+------------------------------------------+
| /etc/nginx/testsite.conf:18 | / | http -> include -> server -> location |
| /etc/nginx/sites/http.testalex.hypernode.io.conf:8 | / | server -> location |
| /etc/nginx/magento2.conf:17 | / | server -> include -> include -> location |
+----------------------------------------------------+--------+------------------------------------------+
You can search for multiple directives, as long as you specify >=n-1 values to directives. F.e., find the server_name
s and location
s that match with location=/static/
:
app@wifbtb-testalex-magweb-cmbl:~$ nginx-static-analysis directive location server_name --value /static/
+------------------------------------------------------+-----------------------+------------------------------------------+
| File | Values | Directives |
+------------------------------------------------------+-----------------------+------------------------------------------+
| /etc/nginx/monitoring.conf:5 | localhost | http -> include -> server -> server_name |
| /etc/nginx/testsite.conf:5 | magweb | http -> include -> server -> server_name |
| /etc/nginx/sites/https.testalex.hypernode.io.conf:21 | testalex.hypernode.io | server -> server_name |
| /etc/nginx/magento2.conf:23 | /static/ | server -> include -> include -> location |
+------------------------------------------------------+-----------------------+------------------------------------------+
By default it parses /etc/nginx/nginx.conf
and all includes, but you can specify the starting file:
app@wifbtb-testalex-magweb-cmbl:~$ nginx-static-analysis -f /some/other/nginx.conf directive location
...
Feeding logs into the analysis
You can feed access/error logs into the analysis by piping it into stdin:
app@wifbtb-testalex-magweb-cmbl:~$ tail /var/log/nginx/access.log -n1 | nginx-static-analysis d location
+----------------------------------------------------+--------+------------------------------------------+
| File | Values | Directives |
+----------------------------------------------------+--------+------------------------------------------+
| /etc/nginx/testsite.conf:18 | / | http -> include -> server -> location |
| /etc/nginx/sites/http.testalex.hypernode.io.conf:8 | / | server -> location |
| /etc/nginx/magento2.conf:17 | / | server -> include -> include -> location |
+----------------------------------------------------+--------+------------------------------------------+
The analysis creates filters based on the incoming loglines. Those filters are combined with the arguments given
to the nginx-static-analysis
command.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Hashes for nginx-static-analysis-0.1.7.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 36d7179bd867805813908e4bc6afdb7fa00585a77232fef43c581c137a3cbb24 |
|
MD5 | c42fd96f7409fa3aeff7858fa99760b4 |
|
BLAKE2b-256 | aa2664a83d9590bdeedee07939ebb6d9f82ba606ad6ab5b052b36abaf58bab46 |