webserver

package
v1.3.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SetupApacheUABlock

func SetupApacheUABlock(report EventReporter) error

SetupApacheUABlock performs one-time Apache UA blocking setup. Supports both Debian (a2enconf) and RHEL (conf.d direct) layouts.

func SetupNginxUABlock

func SetupNginxUABlock(report EventReporter) error

SetupNginxUABlock performs one-time nginx UA blocking setup:

  • Writes /etc/nginx/conf.d/defensia-ua-block.conf (map + include)
  • Creates /etc/defensia/ua-blocklist.conf (empty)
  • Injects "if ($defensia_blocked_ua) { return 444; }" into every server block
  • Runs nginx -t + nginx -s reload; rolls back on failure
  • Writes sentinel /etc/defensia/.nginx-ua-ready so this runs only once

func UpdateApacheUABlock

func UpdateApacheUABlock(fps []UAFingerprint, report EventReporter) error

UpdateApacheUABlock regenerates the Apache UA block config and does apachectl graceful. Skips reload if the generated config is identical to the current file.

func UpdateNginxUABlocklist

func UpdateNginxUABlocklist(fps []UAFingerprint, report EventReporter) error

UpdateNginxUABlocklist regenerates /etc/defensia/ua-blocklist.conf and does nginx -s reload. If setup has not completed yet (sentinel absent), writes the file only — reload happens at setup time. Skips reload if the generated config is identical to the current file.

Types

type EventReporter

type EventReporter func(eventType, severity string, details map[string]string)

EventReporter is called when a config error must be reported to the panel.

type UAFingerprint

type UAFingerprint struct {
	Pattern string
	IsRegex bool
}

UAFingerprint holds a user-agent pattern to block at the web server level.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL