Skip to content

Instantly share code, notes, and snippets.

@nk952777
nk952777 / backup2gdrive
Last active May 27, 2021 05:02
backup2gdrive
#!/bin/bash
source /root/.bash_profile
today=$(date +"%Y-%m-%d")
DIR=/root/backup2gdrive/www.wcpweb.xyz/${today}
if [ ! -d "$DIR" ]; then
mkdir -p /root/backup2gdrive/www.wcpweb.xyz/${today}
fi
cd /root/backup2gdrive/www.wcpweb.xyz/${today}
tar zcf wcpweb_web_${today}_"`date +%s`".tar.gz /home/wwwroot/www.wcpweb.xyz
mysqldump -u user -pHEREISYOURPW mydb > mydb_db_${today}_"`date +%s`".sql
@nk952777
nk952777 / ngnix.conf
Created February 12, 2020 03:54 — forked from WhisperingChaos/ngnix.conf
NGINX SSL/TLS Reverse Proxy to Upstream SSL servers.
events {
# nginx requires this section even when applying all default values
}
http {
# Upstream keyword is followed by a url (domain name/IP). This reference encapsulates
# the list of backend servers defined for a virtual proxy. When autnenticating
# a certificate from a backend server, the upstream url is supplied to the
# certificate authentication process instead of the backend server name. See
# the comments associated with proxy_pass below for a detailed discussion.
upstream backend {
server www.facebook.com:443;
server www.google.com:443;
}
server {
listen 80;
server_name localhost;
#charset koi8-r;
#access_log /var/log/nginx/host.access.log main;
@nk952777
nk952777 / setup_iptables.sh
Created January 30, 2018 05:40 — forked from saitodev/setup_iptables.sh
iptables example
#!/bin/sh
# -*- coding: utf-8 -*-
IPTABLES=/sbin/iptables
SERVICE=/sbin/service
SSH_PORT=22
$IPTABLES -F # すべてのチェインの内容を削除
$IPTABLES -P INPUT ACCEPT # INPUTチェインのポリシーをACCEPTにする
@nk952777
nk952777 / letsencrypt_2017.md
Created January 29, 2018 05:51 — forked from cecilemuller/letsencrypt_2020.md
How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

How to setup Let's Encrypt for Nginx on Ubuntu 16.04 (including IPv6, HTTP/2 and A+ SLL rating)

There are two main modes to run the Let's Encrypt client (called Certbot):

  • Standalone: replaces the webserver to respond to ACME challenges
  • Webroot: needs your webserver to serve challenges from a known folder.

Webroot is better because it doesn't need to replace Nginx (to bind to port 80).

In the following, we're setting up mydomain.com. HTML is served from /var/www/mydomain, and challenges are served from /var/www/letsencrypt.

@nk952777
nk952777 / etcd centos init.d script
Created September 18, 2017 07:40 — forked from aputs/etcd centos init.d script
etcd init script
#!/bin/bash
# Startup script for etcd
#
# chkconfig: 2345 20 80
# description: Starts and stops etcd
. /etc/init.d/functions
prog="etcd"
ETCD_BIN=$(which etcd 2> /dev/null)
# /etc/sysctl.conf
net.ipv4.ip_local_port_range = 1024 65535
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.ipv4.tcp_rmem = 4096 87380 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_fin_timeout = 10
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_timestamps = 0
@nk952777
nk952777 / nginx-tuning.md
Created August 17, 2017 13:04 — forked from denji/nginx-tuning.md
NGINX tuning for best performance

Moved to git repository: https://github.com/denji/nginx-tuning

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.

@nk952777
nk952777 / benchmark+go+nginx.md
Created June 15, 2017 07:32 — forked from hgfischer/benchmark+go+nginx.md
Benchmarking Nginx with Go

Benchmarking Nginx with Go

There are a lot of ways to serve a Go HTTP application. The best choices depend on each use case. Currently nginx looks to be the standard web server for every new project even though there are other great web servers as well. However, how much is the overhead of serving a Go application behind an nginx server? Do we need some nginx features (vhosts, load balancing, cache, etc) or can you serve directly from Go? If you need nginx, what is the fastest connection mechanism? This are the kind of questions I'm intended to answer here. The purpose of this benchmark is not to tell that Go is faster or slower than nginx. That would be stupid.

So, these are the different settings we are going to compare:

  • Go HTTP standalone (as the control group)
  • Nginx proxy to Go HTTP
  • Nginx fastcgi to Go TCP FastCGI
  • Nginx fastcgi to Go Unix Socket FastCGI
@nk952777
nk952777 / etcd.md
Created June 14, 2017 09:32 — forked from diegopacheco/etcd.md
How to Build and Install Etcd on Amazon Linux / CentOS?

Install Go and git, Download Etcd from github and build

sudo yum install -y golang git
go version
sudo git clone https://github.com/coreos/etcd
cd etcd
sudo ./build