Documentation ¶
Overview ¶
Package traefik_modsecurity_plugin is a plugin for the Traefik reverse proxy that integrates ModSecurity, a widely-used Web Application Firewall (WAF).
Index ¶
- func New(ctx context.Context, next http.Handler, config *Config, name string) (http.Handler, error)
- type CacheKeyConditions
- type CacheKeyOptions
- type Config
- type Modsecurity
- func (a *Modsecurity) GetCachedResponse(req *http.Request, options CacheKeyOptions) (*http.Response, error)
- func (a *Modsecurity) HandleCacheAndForwardRequest(req *http.Request) (*http.Response, error)
- func (a *Modsecurity) HandleRequestBodyMaxSize(rw http.ResponseWriter, req *http.Request) error
- func (a *Modsecurity) PrepareForwardedRequest(req *http.Request) (*http.Response, error)
- func (a *Modsecurity) ServeHTTP(rw http.ResponseWriter, req *http.Request)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CacheKeyConditions ¶
CacheKeyConditions contains the conditions for generating a cache key.
type CacheKeyOptions ¶
type CacheKeyOptions struct { IncludeHeaders *bool Headers []string IncludeHost *bool IncludeRemoteAddress *bool }
CacheKeyOptions contains the options for generating a cache key.
type Config ¶
type Config struct { TimeoutMillis int64 `json:"timeoutMillis"` // Timeout for HTTP requests to the ModSecurity server. ModSecurityUrl string `json:"modSecurityUrl,omitempty"` // The URL of the ModSecurity server. MaxBodySize int64 `json:"maxBodySize"` // Maximum allowed size of the request body. // Enable or disable cache globally. CacheEnabled *bool `json:"cacheEnabled,omitempty"` // CacheConditionsMethods specifies the HTTP methods for which caching is allowed. CacheConditionsMethods []string `json:"cacheConditionsMethods,omitempty"` // CacheConditionsNoBody specifies if requests with no body (content-length of 0) should be cached. CacheConditionsNoBody *bool `json:"cacheConditionsNoBody,omitempty"` // CacheKeyIncludeHeaders specifies if the headers should be included in the cache key. CacheKeyIncludeHeaders *bool `json:"cacheKeyIncludeHeaders,omitempty"` // CacheKeyHeaders lists the specific headers to be included in the cache key when CacheKeyIncludeHeaders is true. CacheKeyHeaders []string `json:"cacheKeyHeaders,omitempty"` // CacheKeyIncludeHost specifies if the host should be included in the cache key. CacheKeyIncludeHost *bool `json:"cacheKeyIncludeHost,omitempty"` // CacheKeyIncludeRemoteAddress specifies if the remote address should be included in the cache key. CacheKeyIncludeRemoteAddress *bool `json:"cacheKeyIncludeRemoteAddress,omitempty"` // CacheConditions and CacheKey are structs to store parsed configurations for easy access. CacheConditions CacheKeyConditions CacheKey CacheKeyOptions }
Config holds the plugin configuration.
func CreateConfig ¶
func CreateConfig() *Config
CreateConfig creates a default plugin configuration with predefined values.
type Modsecurity ¶
type Modsecurity struct {
// contains filtered or unexported fields
}
func (*Modsecurity) GetCachedResponse ¶
func (a *Modsecurity) GetCachedResponse(req *http.Request, options CacheKeyOptions) (*http.Response, error)
func (*Modsecurity) HandleCacheAndForwardRequest ¶
func (*Modsecurity) HandleRequestBodyMaxSize ¶
func (a *Modsecurity) HandleRequestBodyMaxSize(rw http.ResponseWriter, req *http.Request) error
HandleRequestBodyMaxSize - handle request body max size
func (*Modsecurity) PrepareForwardedRequest ¶
PrepareForwardedRequest prepares the request to be forwarded to modsecurity.
func (*Modsecurity) ServeHTTP ¶
func (a *Modsecurity) ServeHTTP(rw http.ResponseWriter, req *http.Request)
Click to show internal directories.
Click to hide internal directories.