mirror of https://github.com/wulabing/Xray_onekey
Merge branch 'vndroid-main'
commit
c23b957fee
|
@ -87,17 +87,18 @@ http {
|
|||
listen [::]:80 ipv6only=on;
|
||||
|
||||
charset utf-8;
|
||||
charset_types text/xml application/json;
|
||||
|
||||
location / {
|
||||
auth_basic "";
|
||||
auth_basic_user_file /etc/openresty/auth;
|
||||
add_header Content-Type text/plain;
|
||||
default_type "application/json";
|
||||
return 401 '{"code":401,"status":"Unauthorized","server":"openresty","info":"Please log in again or clear cookies."}';
|
||||
access_log off;
|
||||
}
|
||||
|
||||
location = /auth {
|
||||
auth_basic "";
|
||||
default_type "application/json";
|
||||
auth_basic "Please enter your username and password";
|
||||
auth_basic_user_file /etc/openresty/auth;
|
||||
add_header Content-Type "text/plain; charset=utf-8";
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
content_by_lua_block {
|
||||
|
@ -109,7 +110,9 @@ http {
|
|||
for line in file:lines() do
|
||||
if string.find(line,clientIP) then
|
||||
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
|
||||
ngx.print(k..":"..v.."\n")
|
||||
end
|
||||
|
@ -117,7 +120,7 @@ http {
|
|||
end
|
||||
if m == nil then
|
||||
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
|
||||
io.close(file)
|
||||
os.execute("/usr/local/openresty/nginx/sbin/nginx -s reload")
|
||||
|
@ -125,12 +128,12 @@ http {
|
|||
}
|
||||
|
||||
location = /purge {
|
||||
auth_basic "";
|
||||
default_type 'application/json';
|
||||
auth_basic "Please enter your username and password";
|
||||
auth_basic_user_file /etc/openresty/auth;
|
||||
add_header Content-Type "text/plain; charset=utf-8";
|
||||
content_by_lua_block {
|
||||
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)
|
||||
os.execute("/usr/local/openresty/nginx/sbin/nginx -s reload")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue