本文主要是介绍使用cloudflare+nginxWebUI获取真实IP,自动增加配置的脚本,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!
import requests as rq
import time
#nginxWebUI的host
host = 'nginx-web-ui.xxx.com'
def main():
add_ipv4()
add_ipv6()
add_complete()
def add(ip,name='set_real_ip_from'):
cookies = {#登录后抓取cookie
'SOLONID': '434ecf01a6b04684a1370ed54fe0fd7b',
'SOLONID2': 'eea13621adf4952cdc0b800458feaad7',
}
headers = {
'content-type': 'application/x-www-form-urlencoded; charset=UTF-8',
}
data = [
('id', ''),
('name', name),
('value', ip),
('param', '75'),
('param', 'on'),
('param', '4'),
('param', '4'),
('type', 'js'),
('type', 'css'),
('type', 'json'),
('type', 'xml'),
('param', '1024'),
('param', '32'),
('param', '8'),
('param', '512'),
('param', '51200'),
('param', '6400'),
]
response = rq.post(f'https://{host}/adminPage/http/addOver', cookies=cookies, headers=headers, data=data)
print(response.text)
def add_ipv4():
ip_list_str = rq.get('https://www.cloudflare.com/ips-v4').text
ip_list = ip_list_str.split('\n')
print(ip_list)
for ip in ip_list:
add(ip)
time.sleep(0.1)
def add_ipv6():
ip_list_str = rq.get('https://www.cloudflare.com/ips-v6').text
ip_list = ip_list_str.split('\n')
print(ip_list)
for ip in ip_list:
add(ip)
time.sleep(0.1)
def add_complete():
add('CF-Connecting-IP','real_ip_header')
if __name__=="__main__":
main()
这篇关于使用cloudflare+nginxWebUI获取真实IP,自动增加配置的脚本的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!