VeryNginx

VeryNginx is a very powerful and friendly nginx

introduce

Based on lua_Nginx_Module (OpenRestry), VeryNginx implements advanced firewalls, access statistics, and other features, greatly enhancing the functionality of Nginx itself, and providing a more user-friendly Web interface.

Nginx running status analysis

  • Requests per second
  • The response time
  • The network traffic
  • Network connection number

The request filtering

VeryNginx can filter requests based on the following information:

  • IP
  • UserAgent
  • Request path (URI)
  • Request parameters

VeryNginx presets common filtering rules, which can prevent common SQL injection, Git, SVN file leakage, directory traversal attacks to a certain extent, and intercept common scanning tools.

VeryNginx filters can also support IP black/white list Settings

Access statistics

VeryNginx can count the access to each URI of a website, including each URI:

  • Total number of requests
  • Number of status codes
  • Returns the total number of bytes
  • Average number of bytes per request
  • Total response time
  • Mean response time

And can be analyzed in a variety of order rules.

Installation instructions

Install Nginx/OpenResty

VeryNginx is based on OpenResty1, so you’ll need to install it first

Wget https://openresty.org/download/ngx_openresty-1.9.7.1.tar.gz tar - XVZF ngx_openresty - 1.9.7.1. Tar. Gz CD Ngx_openresty-1.9.7.1 sudo su./configure --prefix=/opt/VeryNginx --user=nginx --group=nginx --with-http_stub_status_module --with-luajit gmake gmake install

VeryNginx actually uses these modules in OpenResty

  • lua-nginx-module
  • http_stub_status_module
  • lua-cjson library

If you don’t want to install OpenResty, or if you already have a working Nginx, you can manually compile and install these modules for Nginx yourself

Deploy VeryNginx

Clone the VeryNginx repository locally and copy the nginx.conf and VeryNginx folders to the nginx working directory.

cd ~
git clone https://github.com/alexazhou/VeryNginx.git
rm -f /opt/VeryNginx/nginx/conf/nginx.conf
cp ~/VeryNginx/nginx.conf /opt/VeryNginx/nginx/conf/nginx.conf
cp -r ~/VeryNginx/VeryNginx /opt/VeryNginx/VeryNginx




Copy the code

Edit the Nginx configuration file

VeryNginx project provides a configuration template/opt/VeryNginx/nginx/nginx. Conf. You need to add your site’s Nginx configuration to this template. But don’t change the part of the code that configureVerynginx (unless you know what you’re doing).

The code to configure VeryNginx is as follows:

#-----------------VeryNginx config code------------------ lua_package_path '/opt/VeryNginx/VeryNginx/lua_script/? .lua;; /opt/VeryNginx/VeryNginx/lua_script/module/? .lua;; '; lua_package_cpath '/opt/VeryNginx/VeryNginx/lua_script/? .so;; '; lua_code_cache on; lua_shared_dict status 1m; lua_shared_dict summary_long 10m; lua_shared_dict summary_short 10m; init_by_lua_file /opt/VeryNginx/VeryNginx/lua_script/on_init.lua; rewrite_by_lua_file /opt/VeryNginx/VeryNginx/lua_script/on_rewrite.lua; access_by_lua_file /opt/VeryNginx/VeryNginx/lua_script/on_access.lua; log_by_lua_file /opt/VeryNginx/VeryNginx/lua_script/on_log.lua; #---------------VeryNginx config code end-----------------Copy the code

If you do not use the configuration template provided by VeryNginx, you can manually add this part to your Nginx configuration file. (If the installation path is not /opt/VeryNginx, you need to change the values of lua_package_cPATH and lua_package_path.)

Start the service

/opt/VeryNginx/nginx/sbin/nginx Copy the code

Stop the service

/opt/VeryNginx/nginx/sbin/nginx -s stopCopy the code

Configure VeryNginx

Open a browser to http://127.0.0.1/VeryNginx/dashboard/index.html.

The default user name and password are verynginx/verynginx.

Once logged in, you can view the status and make changes to the configuration. After modifying the configuration, choose Configuration > System > All Settings to save the modification.

prompt

  • The new configuration takes effect immediately after being saved through the VeryNginx control panel and does not require restart/reload Nginx.

  • VeryNginx storing configuration in/opt/VeryNginx VeryNginx/config. The json.

  • If you are unable to log in due to incorrect configuration options, you can manually delete config.json to clear the configuration.

Enjoy~

Installation

Install Nginx / OpenResty

VeryNginx is based on OpenResty, so you need to install that first.

Wget https://openresty.org/download/ngx_openresty-1.9.7.1.tar.gz tar - XVZF ngx_openresty - 1.9.7.1. Tar. Gz CD Ngx_openresty-1.9.7.1 sudo su./configure --prefix=/opt/VeryNginx --user=nginx --group=nginx --with-http_stub_status_module --with-luajit gmake gmake install

VeryNginx makes use of only the following modules in OpenResty.

  • lua-nginx-module
  • http_stub_status_module
  • lua-cjson library

If you don’t want to install OpenResty, or you already have a working installation of Nginx, you can always prepare your Nginx with those modules manually.

The nginx-extras package from your Linux distro is usually a good start.

Deploy VeryNginx

Checkout VeryNginx repository, link nginx.conf and VeryNginx folder to nginx config dir.

cd ~
git clone https://github.com/alexazhou/VeryNginx.git
rm -f /opt/VeryNginx/nginx/conf/nginx.conf
cp ~/VeryNginx/nginx.conf /opt/VeryNginx/nginx/conf/nginx.conf
cp -r ~/VeryNginx/VeryNginx /opt/VeryNginx/VeryNginx
Copy the code

Configure Nginx

You should add your sites into /opt/VeryNginx/nginx/nginx.conf. However you should not modify the VeryNginx config code In the file unless you know what you’re doing ��

VeryNginx config code looks like the following:

#-----------------VeryNginx config code------------------ lua_package_path '/opt/VeryNginx/VeryNginx/lua_script/? .lua;; /opt/VeryNginx/VeryNginx/lua_script/module/? .lua;; '; lua_package_cpath '/opt/VeryNginx/VeryNginx/lua_script/? .so;; '; lua_code_cache on; lua_shared_dict status 1m; lua_shared_dict summary_long 10m; lua_shared_dict summary_short 10m; init_by_lua_file /opt/VeryNginx/VeryNginx/lua_script/on_init.lua; rewrite_by_lua_file /opt/VeryNginx/VeryNginx/lua_script/on_rewrite.lua; access_by_lua_file /opt/VeryNginx/VeryNginx/lua_script/on_access.lua; log_by_lua_file /opt/VeryNginx/VeryNginx/lua_script/on_log.lua; #---------------VeryNginx config code end-----------------Copy the code

You can have your own Nginx installation to work with VeryNginx by integrating its config code into you own config file.

Start service

/opt/VeryNginx/nginx/sbin/nginx

Stop service

/opt/VeryNginx/nginx/sbin/nginx -s stop

Configure VeryNginx

Open your web browser and go to http://127.0.0.1/VeryNginx/dashboard/index.html.

Default user and password is verynginx / verynginx. You should be able to work through all the options now.

Don’t forget to visit Configuration > System > All Settings to save your changes.

Tips

  • New configs will be effective immediately upon saving. It’s not necessary to restart or reload nginx.

  • When you save config, VeryNginx will write all configs to /opt/VeryNginx/VeryNginx/config.json.

  • If you lock yourself out of VeryNginx by doing something stupid, you can always delete config.json to revert VeryNginx to its default.

Enjoy~


  1. OpenResty is an Nginx rerelease that includes the standard Nginx and many extension modules. ↩