GithubHelp home page GithubHelp logo

bbx-github / vhost-discovery-tool Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lebe-dev/vhost-discovery-tool

0.0 0.0 0.0 240 KB

Gather urls from nginx\apache configs then outputs in Zabbix Low Level Discovery format.

Rust 100.00%

vhost-discovery-tool's Introduction

Virtual Host Discovery Tool

Русская версия

Gather urls from nginx\apache configs then outputs in Zabbix Low Level Discovery format.

Use --use-data-property option for Zabbix < 4.2 (see details in Options section).

Quick start

  1. Copy vhdt to /usr/bin.
  2. Copy zabbix agent config vhost-discovery.conf to /etc/zabbix/zabbix-agent.d/vhost-discovery.conf
  3. Import vhost-discovery-template.xml to Zabbix Server.
  4. Update permissions:
chmod +x /usr/bin/vhdt
chown -R zabbix: /var/log/zabbix
setfacl -Rm u:zabbix:rx /etc/nginx/conf.d
setfacl -Rm u:zabbix:rx /etc/nginx/sites-enabled
  1. Add Virtual Hosts template to target host.
  2. (Optional) Use wszl tool. It creates web-scenarios+triggers based on vhost items.

How it works

Tool looking for nginx\apache configuration files then creates data structures for Low Level Discovery:

  • domain
  • url

Limitations

1. Nginx: Multiple values in server_name

Example: server_name toys.com www.toys.com

Domain toys.com will be collected.

Create issue if you want all domains and explain it.

2. Redirect limitations

If your vhost has row:

return 301 http...

Not inside location directive, it will be excluded from results.

HTTP

Add _http postfix for domain with http protocol. For example: http://somesite.ru will be:

{
  "{#NAME}":"somesite.ru_http",
  "{#URL}":"http://somesite.ru"
}

Processing for nginx configs

Tool ignores hosts which don't have server_name property.

Options

Working directory

Option: --work-dir or -d

Default value: /etc/zabbix

Recursive mode

Enable recursive scan for sub-directories.

Option: -r

Default value: false

Nginx configs root

Option: --nginx-vhosts-path or -n

Default value: /etc/nginx/conf.d

Apache configs root

Option: --apache-vhosts-path or -a

Default value: /etc/httpd/conf.d

Show results with custom ports

Standard ports: 80, 443

Option: --include-custom-ports

Example: http://somehost.ru:3823.

Filter vhosts by domain masks

Option: --ignore-by-masks or -i

Example:

vhdt -i "^test,rfid$,demo"

Will ignore vhosts with domain names starts with test or ends with rfid or contain demo.

Support Zabbix < 4.2

Zabbix 4.2 has JSON format:

{
  "data": []
}

Later versions don't support data property. Use --use-data-property option for that.

Output example

[
    {
        "{#NAME}":"somesite.ru",
        "{#URL}":"https://somesite.ru"
    },
    {
        "{#NAME}":"15.128.42.21:2231",
        "{#URL}":"http://15.128.42.21:2231"
    }
]

Troubleshooting

Log: /var/log/zabbix/vhdt.log.

Couldn't access to /etc/nginx directory

Fix:

setfacl -Rm u:zabbix:rx /etc/nginx/conf.d

or

setfacl -Rm u:zabbix:rx /etc/nginx/sites-enabled

Logging levels

Use --log-level option if you want to switch logging level.

Supported levels: debug, error, warn, trace, info, off

How to disable logging

--log-level=off

Thanks for support

Thanks for project support, testing and feedback:

vhost-discovery-tool's People

Contributors

lebe-dev avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.