Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
O

OpenWAF

> DevOps
Open source

Web security protection system based on openresty

777 stars0 likes0 views
WebsiteGitHub

About

Web security protection system based on openresty

Name

OpenWAF

The first all-round open source Web security protection system, more protection than others.

Table of Contents

  • Name
  • Version
  • Synopsis
  • Description
  • Installation
  • Community
    • English Mailing List
    • Chinese Mailing List
    • Personal QQ Mail
  • Bugs and Patches
  • TODO
  • Changes
  • Copyright and License
  • Modules Configuration Directives
  • Nginx Variables
  • SecRules
    • Variables
    • Transformation Functions
    • Operators
    • Others
  • Donation

Version

This document describes OpenWAF v1.1 released on Mar 8, 2021.

Dockerfile and Docker Images have been upgraded to version 1.1 on Mar 8, 2021.

Synopsis

…
json
    #default_config-json

    #main_safe_policy-json

Back to TOC

Description

  OpenWAF is the first fully open source Web application protection system (WAF), based on nginx_lua API analysis of HTTP request information. OpenWAF is composed of two functional engines: behavior analysis engine and rule engine. The rule engine mainly analyzes the individual requests, and the behavior analysis engine is mainly responsible for the tracking of the request information.
  Rule engine inspired by modsecurity and freewaf(lua-resty-waf), the ModSecurity rules will be implemented using lua. The rule engine can be based on the protocol specification, automatic tools, injection attacks, cross site attacks, information leaks and other security exception request, adding support for dynamic rules, timely repair vulnerabilities.
  Behavior analysis engine including fuzzy identification based on frequency, anti malware crawler, human-computer identification anti detection module, anti CSRF, anti CC, anti right, protection against attack file upload module, cookie tamper proof, anti-theft chain, custom headers and attack response page proof module of information disclosure.
  In addition to the two engines, but also includes statistics, log, attack response page, access rules and other basic modules. In addition to the existing functional modules, OpenWAF also supports dynamic modification of the configuration, the dynamic addition of third party modules, so that the engine does not restart under the conditions of the outage, upgrade protection.
  OpenWAF supports the above features as a strategy for different web application applications with different strategies to protect. The future will build a cloud platform, the strategy can also be shared for others.

basic modules:

  • openwaf_conf
  • openwaf_log
  • openwaf_reqstat
  • openwaf_core
  • openwaf_access_rule

safe modules:

  • openwaf_rule_engine
  • openwaf_attack_response
  • openwaf_api
  • openwaf_anti_mal_crawler
  • openwaf_anti_cc

Detailed configuration documents and examples, please refer to the above module documentation

Back to TOC

Installation

请看 OpenWAF 安装文档

Back to TOC

Community

English Mailing List

The OpenWAF-en mailing list is for English speakers.

Chinese Mailing List

The OpenWAF-cn mailing list is for Chinese speakers.

Personal QQ Mail

[email protected]

QQ Group

579790127

Back to TOC

Bugs and Patches

Please submit bug reports, wishlists, or patches by

  1. creating a ticket on the GitHub Issue Tracker,
  2. or posting to the OpenWAF community.

Back to TOC

TODO

  • Add access_rule module dynamic switch
  • Support connecting SSO
  • Dynamic token
  • APISG(API Security gateway)
  • Mock

Back to TOC

Changes

Changelog

Back to TOC

Copyright and License

This module is licensed under the BSD license.

Copyright (C) 2016-2016, by Jian "Miracle" Qi (齐健) , Titan Co.Ltd.

All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  • Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.

  • Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Back to TOC

Modules Configuration Directives

  • twaf_access_rule
  • twaf_anti_hotlink
  • twaf_anti_mal_crawler
  • twaf_reqstat
  • twaf_log
  • twaf_secrules
  • twaf_anti_cc

Back to TOC

twaf_access_rule

…

rules

syntax: "rules": table

default: none

context: twaf_access_rule

table类型,接入规则,顺序匹配

user

syntax: "user": string

default: -

context: twaf_access_rule:rules

string类型。用户名ID。对应变量 %{USERID}。

非必填,默认值"-".

ngx_ssl

syntax: "ngx_ssl": true|false

default: false

context: twaf_access_rule:rules

boolean类型,服务器端(nginx)认证开关,可与client_ssl组成双向认证

非必填,默认值false

ngx_ssl_cert

syntax: "ngx_ssl_cert": "path"

default: none

context: twaf_access_rule:rules

string类型,服务器端(nginx)认证所需PEM证书地址,目前仅支持绝对地址

ngx_ssl_key

syntax: "ngx_ssl_key": "path"

default: none

context: twaf_access_rule:rules

string类型,服务器端(nginx)认证所需PEM私钥地址,目前仅支持绝对地址

host

syntax: "host": "ip|domain name regex"

default: none

context: twaf_access_rule:rules

string或数组类型。发布域名。(从 v1.0.0β 版本开始支持数组)

支持正则表达式(匹配时,自动忽略大小写)。

同时支持IPv4/IPv6。(从 v1.0.0β 版本开始支持IPv6)

例如:

    "host": "^1\\.1\\.1\\.1$"
    "host": "test\\.com"
    "host": "^.*\\.com$"
    "host": "www.baidu.com"
    "host": ["www.baidu.com", "1.1.1.1", "8888::192.168.1.1"]

port

syntax: "port": number

default: 80|443

context: twaf_access_rule:rules

number或数组类型,端口号。(从 v1.0.0β 版本开始支持数组)

非必填,默认值80或443

若"host"参数为数组时,"port"也应为数组。例如:

    "host": ["www.baidu.com", "1.1.1.1", "8888::192.168.1.1"]
    "posrt": [80, 8088, 8099]

path

syntax: "path": "regex"

default: none

context: twaf_access_rule:rules

string类型,路径,支持正则匹配

非必填,默认值"/"

例如:

    "path": "/"
    "path": "/images"
    "path": "/[a|b]test"

url_case_sensitive

syntax: "url_case_sensitive": "true|false"

default: false

context: twaf_access_rule:rules

boolean类型,路径区分大小写(从 v1.0.0β 版本开始支持此参数)

非必填,默认值false(不区分大小写)

server_ssl

syntax: "server_ssl": true|false

default: false

context: twaf_access_rule:rules

boolean类型,OpenWAF向后端服务器连接的ssl开关

非必填,默认值 false

例如:

    upstream test {
    	server 1.1.1.1;
    }
    
    http {
    	server {
    	    listen 80;
    	    server_name _;
    	    
    	    location / {
    	        #server_ssl为true,相当于proxy_pass后为https
    	    	proxy_pass https://test;
    	        #server_ssl为false,相当于proxy_pass后为http
    	    	#proxy_pass http://test;
    	    }
    	}
    }

forward

syntax: "forward": "upstream_uuid"

default: none

context: twaf_access_rule:rules

string类型,forward表示后端服务器的uuid,即upstream的名称

若不使用OpenWAF提供的$twaf_upstream_server变量,则"forward","forward_addr","forward_port"均非必填(从 v1.0.0β 版本开始支持非必填)

…

forward_addr

syntax: "forward_addr": "ip"

default: none

context: twaf_access_rule:rules

string类型,forward_addr表示后端服务器的ip地址(TODO:支持域名)

    upstream test {
        #如:forward_addr值为1.1.1.1
    	server 1.1.1.1;
    }

forward_port

syntax: "forward_port": port

default: 80|443

context: twaf_access_rule:rules

number类型,forward_port表示后端服务器端口号

非必填,默认值80或443

    upstream test {
    	#如:forward_port值为50001
    	server 1.1.1.1:50001;
    }

uuid

syntax: "uuid": "string"

default: random(16)

context: twaf_access_rule:rules

string类型,接入规则的唯一标识

非必填,默认16位随机字符串(从 v1.0.0β 版本开始默认16位随机字符串)

policy

syntax: "policy": "policy_uuid"

default: twaf_default_conf

context: twaf_access_rule:rules

string类型,满足此接入规则的请求,所使用安全策略的uuid

非必填,默认值twaf_default_conf

Back to twaf_access_rule

Back to TOC

twaf_anti_hotlink

json
{
    "twaf_anti_hotlink":{
        "state":false,
        "log_state":true,
        "event_id":"110001",
        "event_severity":"medium",
        "ct_state":false,
        "action_meta":403,
        "action":"DENY",
        "mode":"referer",
        "allow_noreferer":true,
        "cookie_name":"TWAF_AH",
        "uri_ext":["javascript", "css", "html", ""]
    }
}

state

syntax: "state": true|false|"$dynamic_state"

default: false

context: twaf_anti_hotlink

当前模块暂未开源

log_state

syntax: "log_state": true|false|"$dynamic_state"

default: true

context: twaf_anti_hotlink

ct_state

syntax: "ct_state": true|false|"$dynamic_state"

default: false

context: twaf_anti_hotlink

event_id

syntax: "event_id": "string"

default: "110001"

context: twaf_anti_hotlink

event_severity

syntax: "event_severity": "string"

default: "medium"

context: twaf_anti_hotlink

action

syntax: "action": "string"

default: "DENY"

context: twaf_anti_hotlink

action_meta

syntax: "action_meta": "string"|number

default: 403

context: twaf_anti_hotlink

mode

syntax: *"mode": "str

Issues· 13 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ccchttp-floodluanginx

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
CategoryDevOps
PricingOpen source

> Related tools

D
Docker
容器化平台,标准化应用交付
G
GitHub Actions
GitHub 原生 CI/CD 工作流
N
Nginx
高性能 Web 服务器与反向代理