OpenWAF configures local resource access

OpenWAF configures local static resource security access

introduce

OpenWAF (Web Application Firewall) is an open source web application firewall used to protect web applications from various network attacks. It monitors and filters traffic to web applications by integrating with web servers to identify and block potential attacks and malicious behaviors.

OpenWAF has a robust set of security features designed to provide comprehensive protection, including the following:

  1. Attack protection : OpenWAF can detect and block common web attacks such as cross-site scripting (XSS), SQL injection, command injection, cross-site request forgery (CSRF), and path traversal. It analyzes incoming and outgoing data to prevent attacks by identifying malicious requests and specific attack patterns.

  2. Access control : OpenWAF can filter and control traffic according to configured rules, allowing legitimate requests to pass and blocking potential malicious requests. You can set up IP whitelists and blacklists to restrict specific access sources or block known malicious IP addresses.

  3. Session protection : With OpenWAF, you can protect the session mechanism of your web application, preventing session hijacking and session fixation attacks. It verifies the legitimacy of sessions, detects anomalous activity, and blocks malicious session manipulation.

  4. Hotspot protection : OpenWAF can protect hotspot resources in websites to prevent resource abuse and service unavailability caused by frequent requests. It can limit the access frequency of specific resources, and monitor and block abnormal access behaviors.

  5. Logging and monitoring : OpenWAF provides logging and monitoring functions to record detailed information on each request, including access sources, requested URLs, attack attempts and blocked malicious behaviors, etc. By analyzing log data, potential security risks and abnormal behaviors can be discovered in time.

As an open source project, OpenWAF is flexible and customizable, and you can configure and expand it according to your needs. It is compatible with common web servers (such as Nginx and Apache), and provides a rich library of plug-ins and extensions to meet different security needs.

In general, OpenWAF is an important tool to protect the security of web applications, which can help you reduce potential attack threats and protect the security of user data. If you run a web application and are concerned about security, consider using OpenWAF to increase the protection capabilities of your application.

Hope this introduction gave you an initial understanding of OpenWAF. If you have further questions, I'm always here to help! Protect your web application from hackers!

Create our own configuration file

Create a configuration file directory:

mkdir /etc/myconf

Modify the default Nginxconfiguration file of OpenWAF:

vim /etc/ngx_openwaf.conf

Add the directory where our own files are located

include            /etc/myconf/*.conf;

image-20230829150334466

Add our own configuration file in the newly created myconf directory

vim index.conf

document content

server {
     listen       80;
     server_name  域名;
     include      /opt/OpenWAF/conf/twaf_server.conf;
     location / {
            root   静态文件目录;
            index  index.html index.htm;
        }
}

Modify access_rule configuration

vim /opt/OpenWAF/conf/twaf_access_rule.json

image-20230829150728486

Add a forwarding configuration

The host value here must be consistent with the domain name in index.conf

restart nginx

Stop command: /usr/local/openresty/nginx/sbin/nginx -c /etc/ngx_openwaf.conf -s stop

Start command: /usr/local/openresty/nginx/sbin/nginx -c /etc/ngx_openwaf.conf

The above configuration is complete

Guess you like

Origin blog.csdn.net/A_yonga/article/details/132672132
Recommended