[svc]nginx-module-vts第三方模块安装配置
参考:
https://github.com/vozlt/nginx-module-vts#installation
https://github.com/kubernetes/ingress-nginx
nginx-module-vts第三方nginx status模块
安装第三方模块
nginx-module-vts
mkdir /usr/local/nginx/3rdmodules
cd /usr/local/nginx/3rdmodules
git clone git://github.com/vozlt/nginx-module-vts.git
./configure --user=nginx --group=nginx --prefix=/usr/local/tengine-2.1.2 --with-http_stub_status_module --with-http_ssl_module --add-module=/usr/local/nginx/3rdmodules/nginx-module-vts
make && make install
server {
listen 80;
server_name 192.168.x.x;
auth_basic "secret";
auth_basic_user_file /usr/local/nginx/conf/.pass;
location /ngx_status {
stub_status on;
allow 127.0.0.1;
allow 192.168.8.0/24;
allow 192.168.9.0/24;
deny all;
}
location /ngx_statuss {
stub_status on;
vhost_traffic_status_display;
vhost_traffic_status_display_format html;
allow 127.0.0.1;
allow 192.168.8.0/24;
allow 192.168.9.0/24;
deny all;
}
}
nginx测试
直接vim即可,不要用cat加nginx.conf
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
server {
server_name 192.168.x.x;
location /ngx_status {
stub_status on;
}
}
}
nginx status要出来,必须得有server_name
访问时候只有server_name和端口匹配时候才能访问到,不然会报权限问题(被规则拒绝)
stub_status模块默认allow all.
docker run -it --rm --net=host -v /root/nginx.conf:/etc/nginx/nginx.conf:ro -v /etc/localtime:/etc/localtime:ro nginx
mkdir -p /data/nginx-html
echo "maotai" > /data/nginx-html/index.html
docker run -d \
--net=host \
--restart=always \
-v /etc/nginx/nginx.conf:/etc/nginx/nginx.conf:ro \
-v /etc/localtime:/etc/localtime:ro \
-v /data/nginx-html:/usr/share/nginx/html \
--name nginx \
nginx