xavier-hernandez / goaccess-for-nginxproxymanager

GoAccess Docker Image for Nginx Proxy Manager and more...
https://hub.docker.com/r/xavierh/goaccess-for-nginxproxymanager
MIT License
523 stars 39 forks source link

[Feature Request] Add env variable to enable Goaccess Browser List & env variable to define list of custom browsers #162

Closed RobertD502 closed 11 months ago

RobertD502 commented 11 months ago

Great work on this project!

Just wondering if you'd be open to allowing users to enable the goaccess browsers list via an optional env variable. In addition, an extra env variable can be used to add user-defined browsers to the list.

For example, at the moment, my Uptime Kuma instance returns as an Unknown browser in goaccess (I added a custom user-agent of "Kuma (X11; Linux x86_64)"). In order to get around this, after the image has been updated, I have to edit the start.sh script by adding the following lines:

browser_list_path="/goaccess/config/browsers.list"
echo -e "Kuma\tUptime" >> ${browser_list_path}

In addition, I have to manually edit the npm.sh file to enable the browsers list for goaccess:

Within the npm_init() function the following is added:

browser_file="/goaccess/config/browsers.list"

And within the npm_goaccess_config() function the following is added:

echo "browsers-file ${browser_file}" >> ${goan_config}

Perhaps, with an env variable such as ENABLE_BROWSERS_LIST, if a user sets it to True, then the browsers-file option is added to the goan_config. For the custom browsers, an env variable such as CUSTOM_BROWSERS can be used where, if ENABLE_BROWSERS_LIST is set to True, the custom browsers are added to goaccess' browser list file (done in the start.sh script). The custom browsers defined in the CUSTOM_BROWSERS env variable should be comma delimited so we can add a tab between the Browser and the category of the browser (since the browser list expects a tab between the browser and browser category). In my example, Kuma is the browser and Uptime is the category.

Doing this would allow users to have a more robust understanding of their logs when they have services hitting their servers that have custom user-agents instead of them resulting in Unknown browser logs.

Since I use NPM logs, my example above only deals with the npm.sh script. Enabling the browser-list option would also need to be added to the other log scripts. In addition, since the start.sh script runs whenever the container is restarted, a check of the browser list would need to be done to ensure a user provided browser is only added if it isn't already in the list - not doing so would result in duplicate entries whenever the container is restarted.

Example when using custom browser: image

RobertD502 commented 11 months ago

I've opened PR #163 to incorporate this new feature.

xavier-hernandez commented 11 months ago

@RobertD502 this was incorporated into the new version.

RobertD502 commented 11 months ago

@xavier-hernandez Thank you!