29 Star 46 Fork 18

0ldm0s / VeryNginx

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
LGPL-3.0

VeryNginx

VeryNginx is a very powerful and friendly nginx .

##版权说明

这个软件的原作者并不是我。我只是去除了openrestry包的依赖,并且可以直接自动化安装而已。

目前测试通过的版本是ubuntu 14.04 TLS,其他版本暂时未测试。

原作者网站

##介绍

VeryNginx 基于 lua_nginx_module(openrestry) 开发,实现了高级的防火墙、访问统计和其他的一些功能。 强化了 Nginx 本身的功能,并提供了友好的 Web 交互界面。

###Nginx 运行状态分析

  • 每秒请求数
  • 响应时间
  • 网络流量
  • 网络连接数

Nginx 运行状态

###请求过滤 VeryNginx 可以基于按照以下信息对请求进行过滤:

  • IP
  • UserAgent
  • 请求路径 (URI)
  • 请求参数

Nginx 运行状态

VeryNginx 预置了常用的过滤规则,可以在一定程度上阻止常见的 SQL 注入、Git 及 SVN 文件泄露、目录遍历攻击,并拦截常见的扫描工具。

同时 VeryNginx 的过滤器还支持 IP 黑/白名单设置

###访问统计

VeryNginx 可以统计网站每个URI的访问情况,包括每个URI的:

  • 总请求次数
  • 各状态码次数
  • 返回总字节数
  • 每请求平均字节数
  • 总响应时间
  • 平均响应时间

并且可以按各种规则排序进行分析。

Nginx 运行状态

##安装说明

安装 Nginx / OpenResty

VeryNginx 基于 OpenResty[^openresty],所以你需要先安装它:

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 实际使用到了 OpenResty 中的这些模块

如果你不想安装 OpenResty,或者你已经有了一个正在工作的 Nginx,你也可以自己手动为 Nginx 编译安装这些模块

部署 VeryNginx

克隆 VeryNginx 仓库到本地, 复制 nginx.conf 和 VeryNginx 文件夹到 Nginx 的工作目录.

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
# 下面是使 /opt/VeryNginx 对 nginx 是可写的, 这样 VeryNginx 可以把自己的配置保存在里面
# 修改/opt/VeryNginx目录的所有者为nginx用户
chown -R nginx:nginx /opt/VeryNginx

编辑 Nginx 配置文件

VeryNginx 项目提供了一个配置模版 /opt/VeryNginx/nginx/nginx.conf。你需要把自己站点的 Nginx 配置加到这个模版里面。 但是记得不要修改配置 VeryNginx 的那部分代码(除非你知道自己在干啥 😈)。

配置 VeryNginx 的代码是下面这部分:

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

如果不使用 VeryNginx 提供的配置模版,你也可以手动把这部分加入到自己的 Nginx 配置文件中. (如果安装路径不是 /opt/VeryNginx,需要对 lua_package_cpathlua_package_path 的值进行修改)

##启动服务 /opt/VeryNginx/nginx/sbin/nginx

##停止服务 /opt/VeryNginx/nginx/sbin/nginx -s stop

##对 VeryNginx 进行配置 打开浏览器访问 http://127.0.0.1/VeryNginx/dashboard/index.html

默认用户名和密码是 verynginx / verynginx

登录之后就可以查看状态,并对配置进行修改了。修改配置后,记得到 「配置 > 系统 > 全部配置」去保存.

提示

  • 通过 VeryNginx 控制面板保存新配置之后,会立刻生效,并不需要 restart/reload Nginx。

  • VeryNginx 把配置保存在 /opt/VeryNginx/VeryNginx/config.json 里面。

  • 如果因为配错了什么选项,导致无法登录,可以手动删除 config.json 来清空配置。

###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.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 uses only following modules in OpenResty.

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

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

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 "配置 > 系统 > 全部配置" 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~

[^openresty]: OpenResty 是一个Nginx再发行版本,包含了标准Nginx以及很多扩展模块.

GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/> Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

简介

自己改的VeryNginx。主要是增加了对apt安装的默认nginx的支持。 展开 收起
C
LGPL-3.0
取消

发行版

暂无发行版

贡献者

全部

近期动态

加载更多
不能加载更多了
C
1
https://gitee.com/0ldm0s/VeryNginx.git
git@gitee.com:0ldm0s/VeryNginx.git
0ldm0s
VeryNginx
VeryNginx
master

搜索帮助