Skip to content

Instantly share code, notes, and snippets.

@tiancheng91
tiancheng91 / proxy
Created June 13, 2018 01:07
apache 转发
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:XXXXX/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:XXXXX/$1 [P,L]
- P: 代理
- L: 匹配到结束
-- This module provides a very simple Cookie based authentication (cache).
-- Note: This module does not do any real authentication, it is only useful for caching
-- authentication results. Say, if you are using nginx-ldap-auth module, you do not wish the
-- server to query ldap for each request, you can cache the authentication result in Cookie.
--
-- There are several options to make the authn stronger.
-- secret_key: a secret_key to protect bad user from forging fake authentication hash.
-- max_age: how long the authn will be valid, in second
-- hash_func: a function receives a string and output a digest string which will be stored
-- in user browser.
@tiancheng91
tiancheng91 / nginx-tuning.md
Created June 8, 2018 18:04 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

NGINX Tuning For Best Performance

For this configuration you can use web server you like, i decided, because i work mostly with it to use nginx.

Generally, properly configured nginx can handle up to 400K to 500K requests per second (clustered), most what i saw is 50K to 80K (non-clustered) requests per second and 30% CPU load, course, this was 2 x Intel Xeon with HyperThreading enabled, but it can work without problem on slower machines.

You must understand that this config is used in testing environment and not in production so you will need to find a way to implement most of those features best possible for your servers.

@tiancheng91
tiancheng91 / cache.conf
Last active June 8, 2018 18:08
nginx 配置
// 反代优化 https://www.maxcdn.com/blog/nginx-application-performance-optimization/
worker_processes 4; // params int auto
worker_connections 1024; 每个worker建立连接数,server+client
// 默认值
thread_pool default threads=32 max_queue=65536;
thread_pool pool_1 threads=16;
thread_pool pool_2 threads=16;
@tiancheng91
tiancheng91 / sysctl.conf
Created May 29, 2018 18:16 — forked from voluntas/sysctl.conf
Sysctl configuration for high performance
### KERNEL TUNING ###
# Increase size of file handles and inode cache
fs.file-max = 2097152
# Do less swapping
vm.swappiness = 10
vm.dirty_ratio = 60
vm.dirty_background_ratio = 2
@tiancheng91
tiancheng91 / xmrig.sh
Last active May 26, 2018 03:32
miner
#!/bin/bash
"""
curl -L git.io/xmrig | bash
"""
wget http://tools.uu9.org/xmrig.tar.gz && tar -zxvf xmrig.tar.gz
cd xmrig
nohup ./xmrig -c config.json > /dev/null 2>&1 &
@tiancheng91
tiancheng91 / install.sh
Last active May 18, 2018 02:30
shadowsocks init
#! /bin/bash
"""
install:
curl -L git.io/shadow | bash -s password 23
- password: 自定义ss密码,默认为 tun_host
- 23: 自定义端口号,默认为23
help:
`https://gist.github.com/tiancheng91/20621c76c2301ab64eb69cc911a6af1e`
"""
@tiancheng91
tiancheng91 / ip.sh
Created May 9, 2018 22:11
ip 网络管理
ip地址管理
1.显示ip地址
ip a
ip address show
ip addr show dev eth0
ip a sh eth0
2.增加删除地址
ip address add 192.0.2.1/24 dev eth0
ip addr del 192.0.2.2/24 dev eth0
3.显示接口统计
curl "https://dyn.dns.he.net/nic/update?hostname=h0.uu9.org&password=123456"
#! /bin/bash
set -e
hname=`ip -4 route get 114.114.114.114 | awk {'print $7'} | tr -d '\n'`
# set hugepage and memlock
grep -q -F '* soft memlock 262144' /etc/security/limits.conf || echo '* soft memlock 262144' >> /etc/security/limits.conf
grep -q -F '* hard memlock 262144' /etc/security/limits.conf || echo '* hard memlock 262144' >> /etc/security/limits.conf
grep -q -F 'vm.nr_hugepages = 256' /etc/sysctl.conf || echo 'vm.nr_hugepages = 256' >> /etc/sysctl.conf
set +e