mirror of https://github.com/wulabing/Xray_onekey
parent
d5d1761214
commit
a7eb0b351a
|
@ -87,15 +87,17 @@ http {
|
||||||
listen [::]:80 ipv6only=on;
|
listen [::]:80 ipv6only=on;
|
||||||
|
|
||||||
charset utf-8;
|
charset utf-8;
|
||||||
|
charset_types text/xml application/json;
|
||||||
|
|
||||||
location / {
|
location / {
|
||||||
auth_basic "";
|
default_type "application/json";
|
||||||
auth_basic_user_file /etc/openresty/auth;
|
return 401 '{"code":401,"status":"Unauthorized","server":"openresty","info":"Please log in again or clear cookies."}';
|
||||||
add_header Content-Type text/plain;
|
access_log off;
|
||||||
}
|
}
|
||||||
|
|
||||||
location = /auth {
|
location = /auth {
|
||||||
auth_basic "";
|
default_type "application/json";
|
||||||
|
auth_basic "Please enter your username and password";
|
||||||
auth_basic_user_file /etc/openresty/auth;
|
auth_basic_user_file /etc/openresty/auth;
|
||||||
add_header Content-Type "text/plain; charset=utf-8";
|
add_header Content-Type "text/plain; charset=utf-8";
|
||||||
proxy_set_header X-Real-IP $remote_addr;
|
proxy_set_header X-Real-IP $remote_addr;
|
||||||
|
@ -109,7 +111,9 @@ http {
|
||||||
for line in file:lines() do
|
for line in file:lines() do
|
||||||
if string.find(line,clientIP) then
|
if string.find(line,clientIP) then
|
||||||
m = string.find(line,clientIP)
|
m = string.find(line,clientIP)
|
||||||
ngx.print("当前IP:"..clientIP.."已存在,无需添加\n\n")
|
ngx.status = 202
|
||||||
|
ngx.print('{"code":202,"status":"Accepted","ip":"'..clientIP..'","server":"openresty","info":"Current IP already exists, no operation."}')
|
||||||
|
ngx.exit(202)
|
||||||
for k, v in pairs(headers) do
|
for k, v in pairs(headers) do
|
||||||
ngx.print(k..":"..v.."\n")
|
ngx.print(k..":"..v.."\n")
|
||||||
end
|
end
|
||||||
|
@ -117,7 +121,7 @@ http {
|
||||||
end
|
end
|
||||||
if m == nil then
|
if m == nil then
|
||||||
io.write("allow "..clientIP..";\n")
|
io.write("allow "..clientIP..";\n")
|
||||||
ngx.print("当前IP:"..clientIP.."已添加至白名单")
|
ngx.print('{"code":200,"status":"OK","ip":"'..clientIP..'","server":"openresty","info":"Current IP added to whitelist."}')
|
||||||
end
|
end
|
||||||
io.close(file)
|
io.close(file)
|
||||||
os.execute("/usr/local/openresty/nginx/sbin/nginx -s reload")
|
os.execute("/usr/local/openresty/nginx/sbin/nginx -s reload")
|
||||||
|
@ -125,12 +129,13 @@ http {
|
||||||
}
|
}
|
||||||
|
|
||||||
location = /purge {
|
location = /purge {
|
||||||
auth_basic "";
|
default_type 'application/json';
|
||||||
|
auth_basic "Please enter your username and password";
|
||||||
auth_basic_user_file /etc/openresty/auth;
|
auth_basic_user_file /etc/openresty/auth;
|
||||||
add_header Content-Type "text/plain; charset=utf-8";
|
add_header Content-Type "text/plain; charset=utf-8";
|
||||||
content_by_lua_block {
|
content_by_lua_block {
|
||||||
file = io.open("/etc/openresty/allow.list","w+")
|
file = io.open("/etc/openresty/allow.list","w+")
|
||||||
ngx.print("IP列表已被清空")
|
ngx.print('{"code":200,"status":"OK","server":"openresty","info":"IP list has been cleared."}')
|
||||||
io.close(file)
|
io.close(file)
|
||||||
os.execute("/usr/local/openresty/nginx/sbin/nginx -s reload")
|
os.execute("/usr/local/openresty/nginx/sbin/nginx -s reload")
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue