VeryNginx install_powerful and user-friendly Nginx

Source: Internet
Author: User
Based on lua_nginx_module (openrestry), VeryNginx provides advanced firewall, access statistics, and other functions. Nginx features are enhanced and a friendly Web interaction interface is provided. Introduction

Based on lua_nginx_module (openrestry), VeryNginx provides advanced firewall, access statistics, and other functions. Nginx features are enhanced and a friendly Web interaction interface is provided.

Nginx running status analysis
  • Requests per second
  • Response time
  • Network Traffic
  • Network Connections

Request Filtering

VeryNginx can filter requests based on the following information:

  • IP
  • UserAgent
  • Request Path (URI)
  • Request Parameters

VeryNginx provides preset filtering rules to prevent common SQL injection, Git and SVN file leakage, directory traversal attacks, and block common scanning tools.

In addition, VeryNginx filters support IP blacklist and whitelist settings.

Access statistics

VeryNginx can calculate the access status of each URI of the website, including the following for each URI:

  • Total number of requests
  • Number of Status Codes
  • Total number of returned bytes
  • Average bytes per request
  • Total Response Time
  • Average Response Time

In addition, you can sort the rules for analysis.

Installation instructions Install Nginx/OpenResty

VeryNginx is based on OpenResty [^ openresty], so you need to install it first:

wget https://openresty.org/download/ngx_openresty-1.9.7.1.tar.gztar -xvzf ngx_openresty-1.9.7.1.tar.gzcd ngx_openresty-1.9.7.1sudo su./configure --prefix=/opt/VeryNginx --user=nginx --group=nginx --with-http_stub_status_module --with-luajitgmakegmake install

VeryNginx actually uses these modules in OpenResty

  • Lua-nginx-module
  • Http_stub_status_module
  • Lua-cjson library

If you do not want to install OpenResty, Or you already have a working Nginx, You can manually compile and install these modules for Nginx.

Deploy VeryNginx

Clone the VeryNginx repository to the local machine, and copy the nginx. conf and VeryNginx folders to the Nginx working directory.

Cd ~ Git clone https://github.com/alexazhou/VeryNginx.gitrm-f/opt/VeryNginx/nginx/conf/nginx. confcp ~ /VeryNginx/nginx. conf/opt/VeryNginx/nginx/conf/nginx. confcp-r ~ /VeryNginx/opt/VeryNginx # The following describes how to make/opt/VeryNginx writable to nginx, in this way, VeryNginx can save its configuration in it # modify the/opt/VeryNginx directory owner as the nginx user chown-R nginx: nginx/opt/VeryNginx
Edit Nginx configuration file

The VeryNginx project provides a configuration template/opt/VeryNginx/nginx. conf. You need to add the Nginx configuration of your site to this template. But remember not to modify the code for configuring VeryNginx (unless you know what you are doing: smiling_imp :).

The code for configuring 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-----------------

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 modify the values of lua_package_cpath and lua_package_path)

Start the service

/Opt/VeryNginx/nginx/sbin/nginx

Stop Service

/Opt/VeryNginx/nginx/sbin/nginx-s stop

Configure VeryNginx

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

The default username and password are verynginx and verynginx.

After logging on, you can view the status and modify the configuration. After modifying the configuration, remember to go to configuration> system> all configuration to save.

Prompt
  • After the new configuration is saved in the VeryNginx control panel, it takes effect immediately without restart/reload Nginx.

  • VeryNginx saves the configuration in/opt/VeryNginx/config. json.

  • If you cannot log on because of the incorrect 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 it first.

wget https://openresty.org/download/ngx_openresty-1.9.7.1.tar.gztar -xvzf ngx_openresty-1.9.7.1.tar.gzcd ngx_openresty-1.9.7.1sudo su./configure --prefix=/opt/VeryNginx --user=nginx --group=nginx --with-http_stub_status_module --with-luajitgmakegmake install

VeryNginx uses only 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 configure 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 directory.

cd ~git clone https://github.com/alexazhou/VeryNginx.gitrm -f /opt/VeryNginx/nginx/conf/nginx.confcp ~/VeryNginx/nginx.conf /opt/VeryNginx/nginx/conf/nginx.confcp -r ~/VeryNginx/VeryNginx /opt/VeryNginx/VeryNginx # The following line makes /opt/VeryNginx writable for nginx, so that VeryNginx can modify configs inside it.# Change user and group name to the actual account.chown -R nginx:nginx /opt/VeryNginx
Configure Nginx

You shoshould add your sites into/opt/VeryNginx/nginx. conf. however you shoshould not modify the VeryNginx config code in the file unless you know what you're doing: smiling_imp :.

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-----------------

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 shoshould be able to work through all the options now.

Don't forget to visit "configuration> system> all configuration" to save your changes.

Tips
  • New configs will be valid tive immediately upon saving. It's not necessary to restart or reload nginx.

  • When you save config, VeryNginx will write all configs to/opt/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 ~

[^ Openresty]: OpenResty is a rerelease version of Nginx, including standard Nginx and many extension modules.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.