All Projects → JoyChou93 → nginxparser

JoyChou93 / nginxparser

Licence: other
use python to parse nginx

Programming Languages

python
139335 projects - #7 most used programming language

nginxparser

功能

用python解析nginx配置,获取server块以及server块每个location的后端ip。

安装

wget https://raw.githubusercontent.com/JoyChou93/nginxparser/master/nginx.py

使用

调用代码

from nginx import NGINX

nginx = NGINX('nginx.conf')
print(nginx.servers)

结果

[{
	'include': 'fastcgi_params',
	'backend': [],
	'port': '80',
	'server_name': 'localhost'
}, {
	'include': '',
	'backend': [{
		'backend_path': '/test',
		'backend_ip': '10.10.10.10:8080 10.10.10.11:8080'
	}],
	'port': '81',
	'server_name': 'test.baidu.com'
}]
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].