Today I would like to share some learning videos with you, click to watch!
- Take you to the bottom of the Java Virtual Machine JVM features
- Wipe out any questions about Redis and punch any interviewer who dares to ask about Redis
A very powerful and friendly nginx based on lua-Nginx-Module (OpenReSTY), with WAF, control panel and dashboard
VeryNginx
VeryNginx is a very powerful and friendly Nginx.
Chinese document
Pay attention to
After V0.2, the input URI for the control panel was moved to /verynginx/index.html
describe
VeryNginx is based on the Lua_nginx_Module (OpenRestry). It implements advanced firewall (WAF), access statistics and some other features. It enhances Nginx functionality and provides a friendly Web interface.
VeryNginx online demo
User/Password: verynginx/verynginx
A full version of the configuration guide can be found at VeryNginx Wiki.
Nginx running status analysis
- Requests per second
- The response time
- Net flows
- Tcp connectinn num
Custom operation
VeryNginx supports custom operations and can perform many operations.
A custom Action consists of two parts, Matcher and Action. The Matcher is used to test whether the request conforms to the rule, and the Action is the logic you want to run.
The advantage of this design is that Matcher includes all selection rules and can be reused, using rules to describe logic that can be very complex.
matching
A Matcher is used to select A portion of all requests, and A Matcher can contain one or more criteria. Currently, the following conditions are supported:
- The client IP
- The host
- The user agent
- URI
- To introduce
- Request the Args
When the request does not conflict with any condition of the Matcher, the request is handled by the Matcher
action
Each Action refers to a Matcher, and will run on the… Select the request Matcher
Now, we have these Action trumpets
- Scheme Lock Locks the Scheme to HTTP or HTTPS
- Redirection Redirects a request
- URI Rewrite internally rewrites the request
- Browser validation uses set-cookies and javascript to verify that the client is a browser and block bot traffic. This action may block search engine spiders, so enable it only when attacked.
- Frequency limit Limits the maximum request time for a specified period of time
- Filter Block Some requests can be WAF
Matcher can select requests based on multiple criteria, so with Filter Action, we get a powerful WAF. The WAF can filter requests with complex rules and return a special status code if the request is blocked.
VeryNginx presets some simple filtering rules to prevent simple SQL injection, Git and SVN file leakage, directory traversal attacks, and common scanning tools.
The back-end
Each Backend references a Matcher and will process the requested Matcher selected
Now we have this Backend
- Proxy Pass Proxy sends requests to other servers
- Static files use local files to process request files
The request of statistical
VeryNginx can record requests for URIs, including these data for each URI:
- All requests count
- Request a count of each status code
- The total number of bytes
- Average bytes
- Total response time
- Mean response time
The installation
Install Nginx/OpenResty
VeryNginx is based on OpenResty, so you need to install it first. But don’t worry, VeryNginx provides a script that executes automatically.
python install.py installCopy the code
Simply run this command and OpenResty and Verynginx will be installed automatically.
Want to use custom nginx?
VeryNginx automatically installs OpenResty, so you don’t need to manually install Nginx (OpenResty).
But if you want to use your own compiled Nginx, that’s fine. You can see some help
Use-own-nginx
usage
Edit the nginx configuration file
VeryNginx configuration file is/opt/VeryNginx openresty/nginx/conf/nginx. Conf. This is a demo. It lets Verynginx run so that you can see verynginx’s dashboard. If you want to do something really useful, you need to edit this file and add your own Nginx configuration to it.
This configuration file adds three include commands to embed Verynginx into the original nginx (openresty)
- Including the/opt/verynginx/verynginx/nginx_conf/in_external. Conf.
- include /opt/verynginx/verynginx/nginx_conf/in_http_block.conf;
- include /opt/verynginx/verynginx/nginx_conf/in_server_block.conf;
These include commands are placed outside of a block that blocks HTTP internal configuration, inside the server configuration block, and Remenber retains these three lines when modifying them. If you add a new server configuration block or HTTP configuration block, you also need to add the appropriate include line to it.
Start/stop/restart the service
#Start Service/opt/verynginx/openresty/nginx/sbin/nginx#Stop Service/opt/verynginx/openresty/nginx/sbin/nginx -s stop#Restart Service/opt/verynginx/openresty/nginx/sbin/nginx -s reloadCopy the code
Configure VeryNginx on the dashboard
Once the service is running, you can view the server status and perform configuration on the dashboard.
The dashboard’s address is http://{{your_machine_address}}/verynginx/index.html.
The default user and password are verynginx/ verynginx. You should now be able to complete all the options.
A full version of the configuration guide can be found in the VeryNginx Wiki.
troubleshooting
If you encounter any problems during installation/configuration/use, refer to the troubleshooting documentation.
troubleshooting
prompt
- The new configuration takes effect as soon as it is saved. There is no need to restart or reload nginx.
- Save the configuration, VeryNginx all configuration will be written to/opt/VeryNginx/VeryNginx/configs/config. Json.
- If the chat on the status page gets stuck, you can click the gear icon in the upper right corner to turn off the animation
- If you lock yourself out of VeryNginx by doing something stupid, you can always delete config.json to restore VeryNginx to its default value.
Update VeryNginx/OpenResty
Over time, VeryNginx will evolve on its own and support newer versions of OpenResty. Newer versions of VeryNginx may support some new features or fix some old bugs. To update your local installation of VeryNginx, simply extract the latest code from Github and run the following command:
#Update VeryNginxpython install.py update verynginx#Update OpenRestypython install.py update openrestyCopy the code
Install.py will retain the old config.json and nginx.conf during the update. This way you won’t lose configuration after updating.
Build VeryNginx Docker Image
After cloning the code to a local file system, you can run the following command:
docker build -t verynginx .docker run verynginxCopy the code
You can then navigate to your browser http://{{your_docker_machine_address}}/verynginx/index.html
You can optionally run docker run -p XXXX :80 verynginx to map container port 80 to XXXX port of the host