Skip to content

Instantly share code, notes, and snippets.

@0xDing
Created March 26, 2019 15:02
Show Gist options
  • Save 0xDing/07664f5f01babda70f4c4c784cca42ee to your computer and use it in GitHub Desktop.
Save 0xDing/07664f5f01babda70f4c4c784cca42ee to your computer and use it in GitHub Desktop.
api reverse proxy
# ubuntu18.04
# enabel BBR
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p
# networking opt
sed -i '/^net.core.netdev_max_backlog/ d' /etc/sysctl.conf
echo "net.core.netdev_max_backlog = 2000" >>/etc/sysctl.conf
sed -i '/net.ipv4.tcp_tw_reuse/d' /etc/sysctl.conf
sed -i '/net.ipv4.tcp_tw_recycle/d' /etc/sysctl.conf
echo "net.ipv4.tcp_tw_reuse = 1" >>/etc/sysctl.conf
sed -i '/net.ipv4.tcp_mtu_probing/d' /etc/sysctl.conf
echo "net.ipv4.tcp_mtu_probing = 1" >>/etc/sysctl.conf
#################
wget http://tengine.taobao.org/download/tengine-2.3.0.tar.gz && tar xvf tengine-2.3.0.tar.gz && cd tengine-2.3.0
apt-get install clang build-essential libpcre3 libpcre3-dev libssl-dev libjemalloc-dev libatomic-ops-dev unzip
wget https://www.zlib.net/zlib-1.2.11.tar.gz && tar xzvf zlib-1.2.11.tar.gz
wget https://www.openssl.org/source/openssl-1.1.1b.tar.gz && tar xzvf openssl-1.1.1b.tar.gz
wget https://github.com/openresty/sregex/archive/master.zip; wget -O replace.zip https://github.com/openresty/replace-filter-nginx-module/archive/master.zip && unzip master.zip && unzip replace.zip
cd sregex-master; make; make install && ln -s /usr/local/lib/libsregex.so.0 /usr/lib/libsregex.so.0;cd ..;
./configure --with-jemalloc --with-libatomic --with-http_v2_module --with-http_ssl_module --with-cc-opt='-I/usr/local/include -m64 -march=native -DTCP_FASTOPEN=23 -g -O3 -fstack-protector --param=ssp-buffer-size=4 -Wformat -Werror=format-security -Wp,-D_FORTIFY_SOURCE=2 -Wno-sign-compare -Wno-string-plus-int -Wno-deprecated-declarations -Wno-unused-parameter -Wno-unused-const-variable -Wno-conditional-uninitialized -Wno-mismatched-tags -Wno-sometimes-uninitialized -Wno-parentheses-equality -Wno-tautological-compare -Wno-self-assign -Wno-deprecated-register -Wno-deprecated -Wno-invalid-source-encoding -Wno-pointer-sign -Wno-parentheses -Wno-enum-conversion -Wno-c++11-compat-deprecated-writable-strings -Wno-write-strings -gsplit-dwarf' --without-http_autoindex_module --without-http_uwsgi_module --without-http_scgi_module --without-http_empty_gif_module --with-http_stub_status_module --with-http_realip_module --with-pcre-jit --with-pcre --with-zlib=./zlib-1.2.11 --with-openssl=./openssl-1.1.1b --with-cc=clang --with-cpp=clang++ --add-module=./replace-filter-nginx-module-master --with-http_gzip_static_module --with-http_secure_link_module --with-http_degradation_module --prefix=/usr/local/nginx
make && make install
######
sudo adduser --system --home /nonexistent --shell /bin/false --no-create-home --disabled-login --disabled-password --gecos "nginx user" --group nginx
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment