Skip to content

Instantly share code, notes, and snippets.

View tang-junjie's full-sized avatar

Bright tang-junjie

  • Freelancer
View GitHub Profile
@tang-junjie
tang-junjie / A Nuxt.js VPS production deployment.md
Created July 8, 2021 18:42 — forked from DreaMinder/A Nuxt.js VPS production deployment.md
Deployment manual for a real-world project built with nuxt.js + koa + nginx + pm2

Example of deployment process which I use in my Nuxt.js projects. I usually have 3 components running per project: admin-panel SPA, nuxt.js renderer and JSON API.

This manual is relevant for VPS such as DigitalOcean.com or Vultr.com. It's easier to use things like Now for deployment but for most cases VPS gives more flexebillity needed for projects bigger than a landing page.

UPD: This manual now compatible with nuxt@2.3. For older versions deployment, see revision history.


Let's assume that you have entered fresh installation of Ubuntu instance via SSH. Let's rock:

@tang-junjie
tang-junjie / default nginx configuration file
Created July 6, 2021 23:40 — forked from skbr1234/default nginx configuration file
The default nginx configuration file inside /etc/nginx/sites-available/default
## Personal note: Muslims are not terrorists and I humbly request my engineering community to help end racism.
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
@tang-junjie
tang-junjie / nginxproxy.md
Created July 5, 2021 23:15 — 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

@tang-junjie
tang-junjie / nginx.conf
Created July 5, 2021 23:12 — forked from unixcharles/nginx.conf
nginx config for http/https proxy to localhost:3000
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
@tang-junjie
tang-junjie / config-highlight.cfg
Created July 3, 2021 19:48 — forked from jaimergp/config-highlight.cfg
Dark highlighting theme for Python IDLE based on SublimeText's Monokai color scheme
# Place this file inside your ~/.idlerc/ folder
# or paste its contents inside
# /path/to/python/idlelib/config-highlight.def
# Adapted from SublimeText's Monokai
[monokai]
normal-foreground= #F8F8F2
normal-background= #272822
keyword-foreground= #F92672
keyword-background= #272822
@tang-junjie
tang-junjie / Netcat.md
Created June 30, 2021 18:10 — forked from Integralist/Netcat.md
Netcat

Install the netcat nc command with Homebrew (otherwise Mac OS X version is really old and the interface is different):

brew install netcat

Use netcat to listen for incoming TCP connections on port 3000:

nc -l -p 3000
@tang-junjie
tang-junjie / lang.map.diff
Created June 29, 2021 22:29 — forked from tkfm-yamaguchi/lang.map.diff
source-highlight's language definition file for YAML
---/usr/share/source-highlight/lang.map.old
+++/usr/share/source-highlight/lang.map
@@ -169,3 +169,5 @@
groovy = groovy.lang
json = json.lang
feature = feature.lang
+yaml = yaml.lang
+yml = yaml.lang
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get autoremove -y
apt-get -y install build-essential wget curl gcc make wget tzdata git libreadline-dev libncurses-dev libssl-dev zlib1g-dev
wget https://github.com/SoftEtherVPN/SoftEtherVPN_Stable/releases/download/v4.36-9754-beta/softether-vpnserver-v4.36-9754-beta-2021.06.07-linux-x64-64bit.tar.gz
tar xzf softether-vpnserver-v4.36-9754-beta-2021.06.07-linux-x64-64bit.tar.gz && rm softether-vpnserver-v4.36-9754-beta-2021.06.07-linux-x64-64bit.tar.gz
cd vpnserver && sudo make
cd ..
sudo mv vpnserver /usr/local && cd /usr/local/vpnserver/
sudo chmod 600 *
@tang-junjie
tang-junjie / cors.nginxconf
Created April 14, 2021 01:05 — forked from pauloricardomg/cors.nginxconf
Nginx configuration for CORS-enabled HTTPS proxy with origin white-list defined by a simple regex
#
# Acts as a nginx HTTPS proxy server
# enabling CORS only to domains matched by regex
# /https?://.*\.mckinsey\.com(:[0-9]+)?)/
#
# Based on:
# * http://blog.themillhousegroup.com/2013/05/nginx-as-cors-enabled-https-proxy.html
# * http://enable-cors.org/server_nginx.html
#
server {
@tang-junjie
tang-junjie / iptables.sh
Created April 13, 2021 21:12 — forked from thomasfr/iptables.sh
iptable rules to allow outgoing DNS lookups, outgoing icmp (ping) requests, outgoing connections to configured package servers, outgoing connections to all ips on port 22, all incoming connections to port 22, 80 and 443 and everything on localhost
#!/bin/bash
IPT="/sbin/iptables"
# Server IP
SERVER_IP="$(ip addr show eth0 | grep 'inet ' | cut -f2 | awk '{ print $2}')"
# Your DNS servers you use: cat /etc/resolv.conf
DNS_SERVER="8.8.4.4 8.8.8.8"
# Allow connections to this package servers