Skip to content

Instantly share code, notes, and snippets.

View yangvipguang's full-sized avatar
🏠
Working from home

杨光 yangvipguang

🏠
Working from home
View GitHub Profile
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yangvipguang
yangvipguang / gist:7a670a727833ca5172af7d409d5fe1f6
Created August 7, 2017 16:29 — forked from chenjiyong/gist:fe1197cfe01ef9e95ad1
golang 中指针的使用及理解
go指针是什么?
定义
所谓指针其实你可以把它想像成一个箭头,这个箭头指向(存储)一个变量的地址。
因为这个箭头本身也需要变量来存储,所以也叫做指针变量。
通过下面的例子可以看出指针地之间的关系。
package main
2
@yangvipguang
yangvipguang / nginx-location
Created January 8, 2017 13:38 — forked from luxixing/nginx-location
nginx location 匹配规则
1 普通匹配,遵循最长匹配规则,假设一个请求匹配到了两个普通规则,则选择匹配长度大的那个
例如:
location /{
[matches]
}
location /test{
[matches]
}
2 精确匹配
location = /{
@yangvipguang
yangvipguang / letsencrypt.md
Created December 14, 2016 16:06 — forked from xrstf/letsencrypt.md
Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

Let's Encrypt on Ubuntu 14.04, nginx with webroot auth

This document details how I setup LE on my server. Firstly, install the client as described on http://letsencrypt.readthedocs.org/en/latest/using.html and make sure you can execute it. I put it in /root/letsencrypt.

As it is not possible to change the ports used for the standalone authenticator and I already have a nginx running on port 80/443, I opted to use the webroot method for each of my domains (note that LE does not issue wildcard certificates by design, so you probably want to get a cert for www.example.com and example.com).

Configuration

For this, I placed config files into etc/letsencrypt/configs, named after <domain>.conf. The files are simple:

@yangvipguang
yangvipguang / le-nginx-renew-DigitalOcean
Last active November 29, 2016 15:19 — forked from thisismitch/le-renew-webroot
Let's Encrypt Auto-Renewal using the Webroot Plugin (Nginx)
#!/bin/bash
web_service='nginx'
config_file="/usr/local/etc/le-renew-webroot.ini"
le_path='/opt/letsencrypt'
exp_limit=30;
if [ ! -f $config_file ]; then
echo "[ERROR] config file does not exist: $config_file"
@yangvipguang
yangvipguang / haproxy.cfg
Created November 24, 2016 16:44 — forked from thisismitch/haproxy.cfg
Let's Encrypt Auto-Renewal script for HAProxy
global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
maxconn 2048
@yangvipguang
yangvipguang / nginx.conf
Created November 24, 2016 16:43 — forked from patmandenver/nginx.conf
Ngnix conf that contains /check url that can go dark if file exists
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
multi_accept on;
global
log 127.0.0.1 syslog
maxconn 1000
user haproxy
group haproxy
daemon
defaults
log global
@yangvipguang
yangvipguang / letsencrypt.sh
Created November 24, 2016 16:43 — forked from patmandenver/letsencrypt.sh
Letsencrypt example
#!/bin/bash
#
# Put in your email and your actual domain name
# Server is for staging/testing not getting live certs
sudo letsencrypt certonly \
--server https://acme-staging.api.letsencrypt.org/directory \
--webroot --webroot-path "/usr/share/nginx/html/" \
--keep-until-expiring \
--text \
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
multi_accept on;