Skip to content

Instantly share code, notes, and snippets.

@beansme
beansme / nginxproxy.md
Created December 14, 2016 03:18 — forked from soheilhy/nginxproxy.md
How to proxy web apps using nginx?

Virtual Hosts on nginx (CSC309)

When hosting our web applications, we often have one public IP address (i.e., an IP address visible to the outside world) using which we want to host multiple web apps. For example, one may wants to host three different web apps respectively for example1.com, example2.com, and example1.com/images on the same machine using a single IP address.

How can we do that? Well, the good news is Internet browsers

@beansme
beansme / phpci.yml
Created September 1, 2016 03:18 — forked from skecskes/phpci.yml
phpci.yml Laravel 5 config
build_settings:
verbose: false
prefer_symlink: false
setup:
composer:
action: "install"
prefer_dist: false
test:
@beansme
beansme / nginx-laravel-5.1.conf
Created April 7, 2016 07:43
nginx-laravel-5.1
#!/bin/bash
mkdir -p /$2/$1/{public_html,log,backup}
touch $1.conf
sudo bash -c cat << __EOF > $1.conf
server {
listen 80;
server_name $1;
root "/$2/$1/public_html/public";
index index.html index.htm index.php;
@beansme
beansme / letsencrypt.md
Created March 19, 2016 14:57 — 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:

@beansme
beansme / nginx.conf
Created January 19, 2016 04:57 — forked from plentz/nginx.conf
Best nginx configuration for improved security(and performance). Complete blog post here http://tautt.com/best-nginx-configuration-for-security/
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@beansme
beansme / update npm
Last active February 28, 2016 09:35
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
sudo ln -sf /usr/local/n/versions/node/5.6.0/bin/node /usr/bin/node
npm install -g cnpm --registry=https://registry.npm.taobao.org
@beansme
beansme / server.md
Created December 14, 2015 14:50 — forked from jtadeulopes/server.md
Server setup with ubuntu, nginx and puma for rails app.

Update and upgrade the system

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo apt-get autoremove
sudo reboot
@beansme
beansme / trim emoji
Created November 6, 2015 07:09
去除表情
preg_replace('/([0-9|#][\x{20E3}])|[\x{00ae}|\x{00a9}|\x{203C}|\x{2047}|\x{2048}|\x{2049}|\x{3030}|\x{303D}|\x{2139}|\x{2122}|\x{3297}|\x{3299}][\x{FE00}-\x{FEFF}]?|[\x{2190}-\x{21FF}][\x{FE00}-\x{FEFF}]?|[\x{2300}-\x{23FF}][\x{FE00}-\x{FEFF}]?|[\x{2460}-\x{24FF}][\x{FE00}-\x{FEFF}]?|[\x{25A0}-\x{25FF}][\x{FE00}-\x{FEFF}]?|[\x{2600}-\x{27BF}][\x{FE00}-\x{FEFF}]?|[\x{2900}-\x{297F}][\x{FE00}-\x{FEFF}]?|[\x{2B00}-\x{2BF0}][\x{FE00}-\x{FEFF}]?|[\x{1F000}-\x{1F6FF}][\x{FE00}-\x{FEFF}]?/u', '', $var);
@beansme
beansme / config.json
Created October 16, 2015 07:45
composer国内镜像 ~/.composer/config.json
{
"repositories": [
{"type": "composer", "url": "http://packagist.phpcomposer.com"},
{"packagist": false}
]
}
#!/usr/bin/env python
# coding=utf8
# author=evi1m0
# website=linux.im
'''
12306 Captcha Picture:
author: Evi1m0@20150316
1. Download Captcha
2. Pic Conver Text