Skip to content

Instantly share code, notes, and snippets.

View SaigyoujiYuyuko233's full-sized avatar
🏡
Work from home

西行寺幽幽子 SaigyoujiYuyuko233

🏡
Work from home
View GitHub Profile
@SaigyoujiYuyuko233
SaigyoujiYuyuko233 / php-netmask2Cidr.php
Created May 7, 2020 16:00
Covert netmask(255.255.255.0) to cidr(/24)
function netmask2Cidr($startIP = "10.198.12.0", $endIP = "10.198.12.255") {
$margin = strlen(decbin((ip2long($endIP) - ip2long($startIP))));
$netmask = decbin(0xFFFFFFFF << $margin & 0xFFFFFFFF);
return substr_count($netmask, "1");
}
location ~ ^/(\.env|\.env.example|vendor|composer.json)
{
return 404;
}
@SaigyoujiYuyuko233
SaigyoujiYuyuko233 / reminder.md
Last active November 14, 2019 10:43
TODO LIST
@SaigyoujiYuyuko233
SaigyoujiYuyuko233 / Terminus-Background.css
Last active October 2, 2019 01:46
Terminus 自定义背景图片 | 暗色适用
body.vibrant{
background-size: cover !important;
background-repeat: no-repeat !important;
background-image: url("file:///${图片路径}") !important;
}
title-bar{
background-color: rgb(5, 21, 25) !important;
}
@SaigyoujiYuyuko233
SaigyoujiYuyuko233 / Real IP behind CDN | Nginx in http
Created July 1, 2019 07:50
Real IP behind CDN | Nginx in http
# in http
http{
map $http_x_forwarded_for $real_ip {
"" $remote_addr;
~^(?P<firstAddr>[0-9\.]+),?.*$ $firstAddr;
}
}
real ip: $real_ip
@SaigyoujiYuyuko233
SaigyoujiYuyuko233 / NginxLogFormat
Last active July 4, 2019 01:46
Nginx Log Format
# all the vars
$args #请求中的参数值
$query_string #同 $args
$arg_NAME #GET请求中NAME的值
$is_args #如果请求中有参数,值为"?",否则为空字符串
$uri #请求中的当前URI(不带请求参数,参数位于$args),可以不同于浏览器传递的$request_uri的值,它可以通过内部重定向,或者使用index指令进行修改,$uri不包含主机名,如"/foo/bar.html"。
$document_uri #同 $uri
$document_root #当前请求的文档根目录或别名
$host #优先级:HTTP请求行的主机名>"HOST"请求头字段>符合请求的服务器名.请求中的主机头字段,如果请求中的主机头不可用,则为服务器处理请求的服务器名称
$hostname #主机名