nginx php.conf配置

location ~ .*\.(php)?$ {
        try_files $uri = 404;
        fastcgi_split_path_info ^(.+\.php)(/.+)$;
        fastcgi_pass  unix:/dev/shm/php-cgi.sock;
        fastcgi_index index.php;
        fastcgi_param SCRIPT_FILENAME $document_root/$fastcgi_script_name;
        include fastcgi_params;
        }
location ~ .*\.(htm|gif|jpg|jpeg|png|bmp|ico|flv|swf|txt|wma)$ { expires  30d;}
location ~ .*\.(js|css)?$ { expires   1d;}
location ~ .*\.(tpl|svn|asp|aspx|jsp|do|mdb|zip|rar|bak|htc)?${ deny all; }
location ~ /0.* { deny all; }
if (!-e $request_filename) { return 444; }


关于LVM丢分区和丢数据(最近又又又发生了)

LVM在linux下灵活划分硬盘空间分区是非常好用的一个东西.

从centos5开始到现在还在用的centos7, 我一直都在和lvm做斗争.

问题其实也简单, 无非就是lv分区导致丢失: 分区的md编号错乱丢失lv, lvremove恢复后丢失lv, 以及还有许多已经忘记的原因.


上月由于机柜搬迁数据中心的问题,  一些宿主服务器子系统较多关机时间太长, 在半路进行了强制关机.

然而在恢复完后就发现一些子系统没有恢复, 由于标签显示是自用的节点又暂时没有时间就延后处理了.

今天清点后发现全是自用的节点, 好在都是非一线重要的东西.


7月底一台快7年的E3 4x1T RAID10的服务器硬盘挂掉导致whmcs数据丢失了一部分重要的数据, 

又因为之前迁移进来后没有做定时数据备份, 好在抢救到的数据能维持正常运行, 覆盖早先的备份后一切正常,

此事算妥善处理完成了.


丢数据的事其实已经亲身遇上过很多次了, 硬盘坏掉和LVM丢分区的事每年都有遇上, 即使有RAID也会翻车的可能.

从第一次在webnx的RAID10挂掉, 到LVM串联硬盘分区, 再到rm -rf 数据库, 以及这次又是RAID的挂掉.


数据备份不能马虎, 一定要做, 且异地备份 本地备份 差异备份 同步备份 都要做上, 数据越重要就越需要做备份.


有2次丢掉财务数据库经验的我总结的经验是, 不是每次都那么幸运可以靠手动修复数据.

有时候没了就是没了, 说啥都没有用.

Let’s Encrypt/Certbot Wildcard SSL certificate

export LC_ALL="en_US.UTF-8"
export LC_CTYPE="en_US.UTF-8"
yum install -y git
cd /opt
git clone https://github.com/certbot/certbot.git
cd certbot && ./certbot-auto
 /opt/certbot/certbot-auto certonly --manual --preferred-challenges dns -d *.域名.后缀

--preferred-challenges dns的参数会要求建立一个_acme-challenge.的txt dns指向记录验证域名.

./certbot-auto certificates


 

yum install install certbot python3-cloudflare python3-certbot-dns-cloudflare  -y
echo "00 04 01 * * certbot renew" >> /etc/cron.monthly/certbot
chmod 644 /etc/cron.monthly/certbot


certbot certonly  --agree-tos --email [email protected]   \
  --dns-cloudflare \
  --dns-cloudflare-credentials /root/cf.ini  \
  -d  '*.baidu.XXX'

comware设置ssh免密码登陆

ssh-keygen -f .ssh/id_rsa.pub -e -m pem | grep -v '\-\-\-\-' | base64 -d | xxd -p #转换已有的rsa key

免密码登陆ssh

####交换机配置
rsa peer-public-key 1                   
public-key-code begin
#此处是转换后的key数据
public-key-code end
peer-public-key end
#
user-interface vty 0 4
authentication-mode aaa
user privilege level 15
protocol inbound ssh
#
aaa
local-user 用户名 password cipher 密码 privilege level 15 #local-user netadmin privilege level 15
local-user 用户名 service-type stelnet 
local-user 用户名 service-type ssh
#
stelnet server enable
ssh user 用户名 authentication-type rsa
ssh user 用户名 assign rsa-key 1
ssh user 用户名 service-type stelnet

设置密码登陆方式

user-interface vty 0 4
authentication-mode aaa
protocol inbound ssh
#
aaa
local-user 用户名 password cipher 密码 privilege level 15
local-user 用户名 service-type stelnet 
local-user 用户名 service-type ssh
#
stelnet server enable
ssh user 用户名 authentication-type password
ssh user 用户名 service-type stelnet


ubuntu把netplan改回ifupdown

The following procedure works for Ubuntu 18.04 (Bionic Beaver)

I. Reinstall the ifupdown package:

# apt-get update
# apt-get install ifupdown

II. Configure your /etc/network/interfaces file with configuration stanzas such as:

source /etc/network/interfaces.d/*
# The loopback network interface
auto lo
iface lo inet loopback
allow-hotplug enp0s3
auto enp0s3
iface enp0s3 inet static
  address 192.168.1.133
  netmask 255.255.255.0
  broadcast 192.168.1.255
  gateway 192.168.1.1
  # Only relevant if you make use of RESOLVCONF(8)
  # or similar...
  dns-nameservers 1.1.1.1 1.0.0.1

III. Make the configuration effective (no reboot needed):

# ifdown --force enp0s3 lo && ifup -a
# systemctl unmask networking
# systemctl enable networking
# systemctl restart networking

IV. Disable and remove the unwanted services:

# systemctl stop systemd-networkd.socket systemd-networkd \
networkd-dispatcher systemd-networkd-wait-online
# systemctl disable systemd-networkd.socket systemd-networkd \
networkd-dispatcher systemd-networkd-wait-online
# systemctl mask systemd-networkd.socket systemd-networkd \
networkd-dispatcher systemd-networkd-wait-online
# apt-get --assume-yes purge nplan netplan.io

Then, you're done.

Note: You MUST, of course, adapt the values according to your system (network, interface name...).

阅读剩余部分...

nginx屏蔽搜索引擎

在http字段下加入一个map做匹配引导

map $http_user_agent $limit_bots {
     default 0;
     ~*(baiduspider|google|soso|bing|yandex|sogou|yahoo|sohu-search|yodao|YoudaoBot|robozilla|msnbot|MJ12bot|NHN|Twiceler) 1;
     ~*(AltaVista|Googlebot|Slurp|BlackWidow|Bot|ChinaClaw|Custo|DISCo|Download|Demon|eCatch|EirGrabber|EmailSiphon|EmailWolf|SuperHTTP|Surfbot|WebWhacker) 1;
     ~*(Express|WebPictures|ExtractorPro|EyeNetIE|FlashGet|GetRight|GetWeb!|Go!Zilla|Go-Ahead-Got-It|GrabNet|Grafula|HMView|Go!Zilla|Go-Ahead-Got-It) 1;
     ~*(rafula|HMView|HTTrack|Stripper|Sucker|Indy|InterGET|Ninja|JetCar|Spider|larbin|LeechFTP|Downloader|tool|Navroad|NearSite|NetAnts|tAkeOut|WWWOFFLE) 1;
     ~*(GrabNet|NetSpider|Vampire|NetZIP|Octopus|Offline|PageGrabber|Foto|pavuk|pcBrowser|RealDownload|ReGet|SiteSnagger|SmartDownload|SuperBot|WebSpider) 1;
     ~*(Teleport|VoidEYE|Collector|WebAuto|WebCopier|WebFetch|WebGo|WebLeacher|WebReaper|WebSauger|eXtractor|Quester|WebStripper|WebZIP|Wget|Widow|Zeus) 1;
     ~*(Twengabot|htmlparser|libwww|Python|perl|urllib|scan|Curl|email|PycURL|Pyth|PyQ|WebCollector|WebCopy|webcraw) 1;
 }


再到server字段或者是location字段下加入if判断

  if ($limit_bots = 1) {  return 403;  }


id_rsa加密码和移除密码

增加密码

openssl rsa -aes256 -in your.key -out your.encrypted.key


移除密码

openssl rsa -in your.key -out your.open.key

id_rsa文件需要400的权限, 否则不能使用.


原文引用自https://stackoverflow.com/questions/42863913/key-load-public-invalid-format

linux系统日志清空

for I in `echo dmesg lastlog messages secure tallylog wtmp btmp maillog spooler yum.log`; do
echo > /var/log/$I;
done
history -c


Supermicro IPMI/BMC nginx proxy

需要安装一个openresty或者nginx, 版本大于1.15.10

编译安装参考http://www.kvm.la/1043.html , openresty二进制包版本较低没有更新, 建议编译安装一份.

首先把IPMI的IP丢进一个ip.list的文件里面, 一行一个IP.

#/bin/bash
i=1000  #vnc start port
b=2000
# hextoip() { hex=$1;  printf "%d." 0x${hex:0:2};  printf "%d." 0x${hex:2:2};  printf "%d." 0x${hex:4:2};  printf "%d" 0x${hex:6:2};  }
#gethostip -x 10.0.12.1
stream_route_map=/etc/nginx/stream.route.map.conf
http_route_map=/etc/nginx/http.route.map.conf
echo " default 0;" > $stream_route_map
echo " default 0;" > $http_route_map
for IP in `cat /root/ipmi/ip.list | uniq -c |awk   '{ print $2 }'`;
do
i=`expr $i + 1` ;
b=`expr $b + 1` ;
HEXIP=`gethostip -x $IP | tr 'A-Z' 'a-z'` ;
echo "	   ~*($IP|$i|$b|$HEXIP)$ 	IP<$IP>|VNC<$i>|BMC<$b>|HEX<$HEXIP>;" >>$http_route_map;
echo "     ~*($b|$i)$  $IP;" >> $stream_route_map

done

nginx -s reload

阅读剩余部分...

WHMCS投诉报告转发工单模版

流程之一, 模版格式化解决繁琐操作.

你好, [NAME] 

请尽快处理我们收到的以下滥用投诉报告,谢谢。
我们收到了来自您订单的投诉报告。我们要求您尽快调查此事。完成调查后,请回复以下问题的答复:
1)问题的根源是什么?
2)您采取了哪些步骤解决此问题?
3)你采取了哪些措施来防止这种情况再次发生?

由于此活动违反了我们的服务条款,因此我们要求您在接下来的12小时内回复。
如果我们在这段时间内没有收到回复,我们可能会暂时中断您的服务,以防止进一步的恶意活动。

=========== COMPLAINT STARTS HERE ============

投诉内容(模版里面去掉此处)
投诉内容(模版里面去掉此处)
投诉内容(模版里面去掉此处)

=========== COMPLAINT ENDS HERE ==============

在此过程中,请继续保持我们的状态更新,如果您有任何问题,请告知我们。

Kind Regards,
公司名 Support


Command | kickstart之中rootpw密码生成方法

一、简介

linux kickstart文件里rootpw密码可以使用明文,也可以使用加密过的值,这里主要介绍下三种加密方法:md5、sha256、sha512

使用明文的方法

rootpw "password"

使用加密的方法

rootpw --iscrypted password_hashauthconfig --enableshadow --enablemd5 (--passalgo=sha256 or --passalgo=sha512)

二、加密生成方法,这里统一用password来加密

1、md5加密

使用openssl passwd命令:

# openssl passwd -1 "password"$1$uMOl6YMI$7AAO8YG7l37ipRXCmmame.

使用grub-crypt命令,会提示输出密码:

# grub-crypt --md5Password:Retype password:$1$Y9TR8PpY$qm1VzsjKzbXtYInyAQLG70

使用python,同样也会提示输出密码:

# echo 'import crypt,getpass; print crypt.crypt(getpass.getpass(), "$1$8_CHARACTER_SALT_HERE")' | python -Password:$1$8_CHARAC$GVWpvO3Hu009C37IYF41L0

阅读剩余部分...

centos7升级到centos8

只负责记录, 升级出了问题责任自负.

yum -y install epel-release yum-utils rpmconf  dnf
yum remove 

# 
# package-cleanup --leaves
# package-cleanup --orphans
#

dnf -y remove yum yum-metadata-parser libsysfs  
dnf upgrade -y
dnf upgrade -y http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/{centos-release-8.1-1.1911.0.8.el8.x86_64.rpm,centos-gpg-keys-8.1-1.1911.0.8.el8.noarch.rpm,centos-repos-8.1-1.1911.0.8.el8.x86_64.rpm}

dnf upgrade -y epel-release
dnf clean all
rpm -e `rpm -q kernel`
rpm -e --nodeps sysvinit-tools
dnf -y --releasever=8 --allowerasing --setopt=deltarpm=false distro-sync
dnf -y install kernel-core
dnf -y groupupdate Core "Minimal Install"
cat /etc/redhat-release


centos8的三个包centos-release centos-gpg-keys centos-repos版本会有变动, 操作的时候需要注意选择更新.

也可以不用http://mirror.centos.org/centos/8/BaseOS/x86_64/os/Packages/ ,选用centos vault的库.


frps服务器一键搭建脚本

wget --no-check-certificate https://raw.githubusercontent.com/clangcn/onekey-install-shell/master/frps/install-frps.sh -O ./install-frps.sh
chmod 700 ./install-frps.sh
./install-frps.sh install


Linux常用性能测试脚本

dd if=/dev/zero of=test bs=64k count=4k oflag=dsync
curl -Ss http://86.re/bench.sh |bash
curl -fsL https://ilemonra.in/LemonBenchIntl | bash -s fast
curl -fsL https://github.com/LemonBench/LemonBench/raw/master/LemonBench.sh | bash -s fast

https://www.91yuntest.com/

wget -N --no-check-certificate https://raw.githubusercontent.com/91yun/91yuntest/master/test.sh && bash test.sh -i "io,bandwidth,chinabw,download,traceroute,backtraceroute,allping,gotoping,benchtest" -u
wget -qO- --no-check-certificate https://raw.githubusercontent.com/oooldking/script/master/superbench.sh | bash
wget https://raw.github.com/sivel/speedtest-cli/master/speedtest.py -O  /usr/local/bin/speedtest
chmod a+rx  /usr/local/bin/speedtest
speedtest
wget http://down.eeqiu.net/besttrace4linux.zip
unzip besttrace4linux.zip
chmod +x besttrace
./besttrace -q 1 gd.189.cn


ST、SC、FC、LC光纤头

日常记录