ini Nginx配置

nginx.conf
user  nginx;
worker_processes  auto;

error_log  /var/log/nginx/error.log warn;
pid        /var/run/nginx.pid;


events {
    worker_connections  1024;
}


http {
    include       /etc/nginx/mime.types;
    default_type  application/octet-stream;

    log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for"';

    access_log  /var/log/nginx/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    keepalive_timeout  65;

    #gzip  on;

    include /etc/nginx/conf.d/*.conf;
}
default.conf
server {
    listen       80;
    server_name  localhost;

    #charset koi8-r;
    #access_log  /var/log/nginx/host.access.log  main;

    location / {
        root   /usr/share/nginx/html;
        index  index.html index.htm;
    }

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

    # proxy the PHP scripts to Apache listening on 127.0.0.1:80
    #
    #location ~ \.php$ {
    #    proxy_pass   http://127.0.0.1;
    #}

    # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
    #
    #location ~ \.php$ {
    #    root           html;
    #    fastcgi_pass   127.0.0.1:9000;
    #    fastcgi_index  index.php;
    #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
    #    include        fastcgi_params;
    #}

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    #location ~ /\.ht {
    #    deny  all;
    #}
}

ini NTP

ntp.conf
driftfile /var/lib/ntp/drift
restrict default nomodify notrap nopeer noquery

restrict 127.0.0.1 
restrict ::1

# Hosts on local network are less restricted.
#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap

server 135.224.18.20 iburst

includefile /etc/ntp/crypto/pw
keys /etc/ntp/keys
disable monitor

ini 网卡

net_alias.conf
# 原始
DEVICE=eth0               
BOOTPROTO=static
IPADDR=222.111.333.255
NETMASK=255.255.255.0
GATEWAY=222.111.333.1
ONBOOT=yes

# 别名
DEVICE=eth0:1
BOOTPROTO=static
IPADDR=192.168.1.189
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
ONBOOT=yes

ini 局域网实用程序唤醒

局域网实用程序唤醒

etc-bash_completion.d-wol.bash
#!/bin/bash

# sudo apt install bash-completion
# sudo cp etc-bash_completion.d-wol.bash /etc/bash_completion.d/wol.bash

_wol() {
    local _cur="${COMP_WORDS[COMP_CWORD]}"
    COMPREPLY=( $(compgen -W "$(wol --list)" -- "$_cur") )
}

complete -F _wol wol
wol
#!/bin/bash

# sudo apt install wakeonlan
# sudo cp wol /usr/local/bin/wol
# sudo chmod 0755 /usr/local/bin/wol

if ! which wakeonlan &> /dev/null; then
    echo Please install 'wakeonlan'
    exit 1
fi

CONFIG_FILE="/path/to/wol.conf"
#CONFIG_FILE="/usr/local/etc/wol.conf"

declare -A settings
param=()

while read line; do
    _e=( ${line/\#*/} )
    _name="${_e[0]}"
    _mac="${_e[1]}"
    if [ "$_name" != "" -a "$_mac" != "" ]; then
        settings["${_name}"]="${_mac}"
    fi
done < "$CONFIG_FILE"

usage () {
    cat << EOL
Usage: ${0##*/} [--list|--all] [ MAC Address | IP Address | Target name ]...

Options:
    --list:     show Target names
    --all:      send magic packet to all target
    -h, --help: show this message
EOL
}

show_target_list () {
    local max_len=0 len
    for name in ${!settings[@]}; do
        len=$((${#name} + 1))
        if [ ${#name} -gt $max_len ]; then
            max_len=$len
        fi
    done

    for name in ${!settings[@]}; do
        printf "%-${max_len}s %s\n" "$name" "${settings[${name}]}"
    done
}

if [[ -z "$1" ]]; then
    show_target_list
else
    for _opt in "$@"; do
        case "$_opt" in
            '--list' )
                show_target_list
                exit 0
                ;;
            '--all' )
                param=(${!settings[@]})
                break
                ;;
            '-h'|'--help' )
                usage
                exit 0
                ;;
            *)
                param+=("$1")
                shift
                ;;
        esac
    done
fi

for e in ${param[@]}; do
    if [ "$(echo "${settings[${e}]}")" != "" ]; then
        wakeonlan "${settings[${e}]}"
    else
        wakeonlan "${e}"
    fi
done
wol-enabler.service
[Unit]
Description=Wake on LAN enabler

[Service]
Type=oneshot
ExecStart=/sbin/ethtool -s eth0 wol g
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target

# sudo cp wol-enabler.service /etc/systemd/system/wol-enabler.service
# sudo systemctl daemon-reload
# sudo systemctl enable wol-enabler.service
wol.conf
# name         MAC-address
http-server    00:11:22:aa:bb:cc
nas-server     99:88:77:ff:ee:dd
pc1            00:00:00:00:00:00

ini NGINX提供远程上传文件

nginx-site.conf
set $remote_server https://www.domain.com/;

location ~ ^/wp-content/uploads/(.*) {
    rewrite ^/wp-content/uploads/(.*)$ $remote_server/wp-content/uploads/$1 permanent;
}

ini Xen配置pfsense

Xen配置pfsense

pfsense.cfg
import os, re
arch = os.uname()[4]
if re.search('64', arch):
    arch_libdir = 'lib64'
else:
    arch_libdir = 'lib'

kernel = "/usr/lib/xen-4.0/boot/hvmloader"
builder = 'hvm'
memory = 768
vcpus = 1

name = "pfsense"

vif = [ 'type=ioemu, bridge=eth0' ]
acpi = 1
apic = 1
disk = [ 'phy:/dev/xen/xen4-freebsd72-00,hda,w', 'file:/home/download/freebsd-7.2-RELEASE-i386-dvd1.iso,hdc:cdrom,r' ]
device_model = '/usr/' + arch_libdir + '/xen-4.0/bin/qemu-dm'
usbdevice='tablet'

# boot on floppy (a), hard disk (c) or CD-ROM (d)
boot='d'

# use vnc for console not sdl, don't start vnc console
vnc=1
sdl=0
vncconsole=0

on_poweroff = 'preserve'
on_reboot   = 'restart'
on_crash    = 'restart'

ini Dev CP Proxy Nextjs

/etc/nginx/plesk.conf.d/vhosts/dev.careersinpoland.com.conf

file.conf
#ATTENTION!
#
#DO NOT MODIFY THIS FILE BECAUSE IT WAS GENERATED AUTOMATICALLY,
#SO ALL YOUR CHANGES WILL BE LOST THE NEXT TIME THE FILE IS GENERATED.

server {
        listen 137.74.169.150:443 ssl http2;

        server_name dev.careersinpoland.com;
        server_name www.dev.careersinpoland.com;
        server_name ipv4.dev.careersinpoland.com;

        ssl_certificate             /opt/psa/var/certificates/certV8VepcN;
        ssl_certificate_key         /opt/psa/var/certificates/certV8VepcN;

        client_max_body_size 128m;

        root "/var/www/vhosts/dev.careersinpoland.com/httpdocs/public";
        access_log "/var/www/vhosts/system/dev.careersinpoland.com/logs/proxy_access_ssl_log";
        error_log "/var/www/vhosts/system/dev.careersinpoland.com/logs/proxy_error_log";

        #extension letsencrypt begin
        location ^~ /.well-known/acme-challenge/ {
                root /var/www/vhosts/default/htdocs;

                types { }
                default_type text/plain;

                satisfy any;
                auth_basic off;
                allow all;

                location ~ ^/\.well-known/acme-challenge.*/\. {
                        deny all;
                }
        }
        #extension letsencrypt end

location / {
     expires max;
     proxy_pass http://127.0.0.1:3000;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection "Upgrade";
     proxy_set_header Host $http_host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forward-Proto http;

}
location /(api|admin|assets|_debugbar) {
     proxy_pass http://137.74.169.150:7080;
     proxy_set_header Host             $host;
     proxy_set_header X-Real-IP        $remote_addr;
     proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
     proxy_set_header X-Accel-Internal /internal-nginx-static-location;
     access_log off;
}

location /internal-nginx-static-location/ {
     alias /var/www/vhosts/dev.karierawfinansach.pl/httpdocs/public/;
     internal;
}

location ~ ^/(plesk-stat|awstats-icon|webstat|webstat-ssl|ftpstat|anon_ftpstat) {
     proxy_pass http://137.74.169.150:7080;
     proxy_set_header Host             $host;
     proxy_set_header X-Real-IP        $remote_addr;
     proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
     proxy_set_header X-Accel-Internal /internal-nginx-static-location;
     access_log off;
}

location ~ ^/(api|admin|assets|_debugbar) {
     proxy_pass http://137.74.169.150:7080;
     proxy_set_header Host             $host;
     proxy_set_header X-Real-IP        $remote_addr;
     proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
     access_log off;
}
location ~ ^/~(.+?)(/.*)?$ {
     proxy_pass http://137.74.169.150:7080;
     proxy_set_header Host             $host;
     proxy_set_header X-Real-IP        $remote_addr;
     proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
     proxy_set_header X-Accel-Internal /internal-nginx-static-location;
     access_log off;
}

location ~ \.php(/.*)?$ {
     fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
     fastcgi_param PATH_INFO $fastcgi_path_info;
     fastcgi_pass "unix:///var/www/vhosts/system/dev.karierawfinansach.pl/php-fpm.sock";
     include /etc/nginx/fastcgi.conf;
}

}

server {
        listen 137.74.169.150:80;

        server_name dev.careersinpoland.com;
        server_name www.dev.careersinpoland.com;
        server_name ipv4.dev.careersinpoland.com;

        client_max_body_size 128m;

        root "/var/www/vhosts/dev.careersinpoland.com/httpdocs/public";
        access_log "/var/www/vhosts/system/dev.careersinpoland.com/logs/proxy_access_log";
        error_log "/var/www/vhosts/system/dev.careersinpoland.com/logs/proxy_error_log";

        #extension letsencrypt begin
        location ^~ /.well-known/acme-challenge/ {
                root /var/www/vhosts/default/htdocs;

                types { }
                default_type text/plain;

                satisfy any;
                auth_basic off;
                allow all;

                location ~ ^/\.well-known/acme-challenge.*/\. {
                        deny all;
                }
        }
        #extension letsencrypt end

location / {
     expires max;
     proxy_pass http://127.0.0.1:3000;
     proxy_http_version 1.1;
     proxy_set_header Upgrade $http_upgrade;
     proxy_set_header Connection "Upgrade";
     proxy_set_header Host $http_host;
     proxy_set_header X-Real-IP $remote_addr;
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
     proxy_set_header X-Forward-Proto http;

}

location /(api|admin|assets|_debugbar) {
     proxy_pass http://137.74.169.150:7080;
     proxy_set_header Host             $host;
     proxy_set_header X-Real-IP        $remote_addr;
     proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
     proxy_set_header X-Accel-Internal /internal-nginx-static-location;
     access_log off;
}

location /internal-nginx-static-location/ {
     alias /var/www/vhosts/dev.karierawfinansach.pl/httpdocs/public/;
     internal;
}

location ~ ^/(plesk-stat|awstats-icon|webstat|webstat-ssl|ftpstat|anon_ftpstat) {
     proxy_pass http://137.74.169.150:7080;
     proxy_set_header Host             $host;
     proxy_set_header X-Real-IP        $remote_addr;
     proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
     proxy_set_header X-Accel-Internal /internal-nginx-static-location;
     access_log off;
}

location ~ ^/(api|admin|assets|_debugbar) {
     proxy_pass http://137.74.169.150:7080;
     proxy_set_header Host             $host;
     proxy_set_header X-Real-IP        $remote_addr;
     proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
     access_log off;
}

location ~ ^/~(.+?)(/.*)?$ {
     proxy_pass http://137.74.169.150:7080;
     proxy_set_header Host             $host;
     proxy_set_header X-Real-IP        $remote_addr;
     proxy_set_header X-Forwarded-For  $proxy_add_x_forwarded_for;
     proxy_set_header X-Accel-Internal /internal-nginx-static-location;
     access_log off;
}

location ~ \.php(/.*)?$ {
     fastcgi_split_path_info ^((?U).+\.php)(/?.+)$;
     fastcgi_param PATH_INFO $fastcgi_path_info;
     fastcgi_pass "unix:///var/www/vhosts/system/dev.karierawfinansach.pl/php-fpm.sock";
     include /etc/nginx/fastcgi.conf;
}

}

ini 反向代理配置

反向代理配置

how-to.md
Don't forget to include `/usr/local/etc/nginx/servers` folder in `/usr/local/etc/nginx/nginx.conf`

with syntax: `include servers/*;`

MacOS location `/usr/local/etc/nginx/servers/sub.domain.dv.conf`
sub.domain.dv.conf
server {
  listen 80;
  listen [::]:80;

  server_name sub.domain.dv;

  location / {
      proxy_pass http://127.0.0.1:318/;
  }
}

ini .tmux.conf

.tmux.conf
# remap prefix from 'C-b' to 'C-a'
unbind C-b
set-option -g prefix C-a
bind-key C-a send-prefix


# split panes using | and -
bind | split-window -h
bind - split-window -v
unbind '"'
unbind %

# reload config file (change file location to your the tmux.conf you want to use)
bind r source-file ~/.tmux.conf

# switch panes using Alt-arrow without prefix
bind -n M-Left select-pane -L
bind -n M-Right select-pane -R
bind -n M-Up select-pane -U
bind -n M-Down select-pane -D

# Enable mouse control (clickable windows, panes, resizable panes)
# set -g mouse-select-window on
# set -g mouse-select-pane on
# set -g mouse-resize-pane on

set -g mouse on
bind -n WheelUpPane if-shell -F -t = "#{mouse_any_flag}" "send-keys -M" "if -Ft= '#{pane_in_mode}' 'send-keys -M' 'copy-mode -e'"
# Make mouse useful in copy mode
#setw -g mode-mouse on
#
# # Allow mouse to select which pane to use
#set -g mouse-select-pane on

# # Allow mouse dragging to resize panes
#set -g mouse-resize-pane on
#
# # Allow mouse to select windows
#set -g mouse-select-window on#

set-option -g allow-rename off

# loud or quiet?
set -g visual-activity off
set -g visual-bell off
set -g visual-silence off
setw -g monitor-activity off
set -g bell-action none

# #  modes
setw -g clock-mode-colour colour5
setw -g mode-style 'fg=colour1 bg=colour18 bold'

# # panes
set -g pane-border-style 'fg=colour19 bg=colour0'
set -g pane-active-border-style 'bg=colour0 fg=colour9'

# # statusbar
set -g status-position bottom
set -g status-justify left
set -g status-style 'bg=colour18 fg=colour137 dim'
set -g status-left ''
set -g status-right '#[fg=colour233,bg=colour19] %d/%m #[fg=colour233,bg=colour8] %H:%M:%S '
set -g status-right-length 50
set -g status-left-length 20

setw -g window-status-current-style 'fg=colour1 bg=colour19 bold'
setw -g window-status-current-format ' #I#[fg=colour249]:#[fg=colour255]#W#[fg=colour249]#F '

setw -g window-status-style 'fg=colour9 bg=colour18'
setw -g window-status-format ' #I#[fg=colour237]:#[fg=colour250]#W#[fg=colour244]#F '

setw -g window-status-bell-style 'fg=colour255 bg=colour1 bold'

# # messages
set -g message-style 'fg=colour232 bg=colour16 bold'

# List of plugins
set -g @plugin 'tmux-plugins/tpm'
set -g @plugin 'tmux-plugins/tmux-sensible'

# # Other examples:
set -g @plugin 'github_username/plugin_name'
set -g @plugin 'git@github.com/user/plugin'
set -g @plugin 'git@bitbucket.com/user/plugin'

# # Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
run -b '~/.tmux/plugins/tpm/tpm'

set -g @plugin 'jimeh/tmux-themepack'

set -g @themepack 'powerline/block/red'

ini Tmux版本验证(适用于v1.8到v2.1)

保存自https://gist.github.com/vincenthsu/6847a8f2a94e61735034e65d17ca0d66

tmux_1.9_down.conf
# User key bindings
    # ^C - create new window
    # c - create new window (default key)
    # \ | % - vsplit
    # - _ " - split
    unbind ^C
    bind ^C new-window;
    bind \ split-window -h
    bind | split-window -h
    bind - split-window -v
    bind _ split-window -v

# Mouse mode is off by default
    # <prefix> M : to turn it off
    # <prefix> m : to turn it on
    unbind m
    bind m set -g mode-mouse on \; set -g mouse-resize-pane on \; set -g mouse-select-pane on \; set -g mouse-select-window on \; display "Mouse ON"
    bind M set -g mode-mouse off \; set -g mouse-resize-pane off \; set -g mouse-select-pane off \; set -g mouse-select-window off \; display "Mouse OFF"
tmux_2.1_up.conf
# User key bindings
    # ^C - create new window
    # c - create new window (default key)
    # \ | % - vsplit
    # - _ " - split
    unbind c
    bind c new-window -c "#{pane_current_path}"
    bind ^C new-window -c "#{pane_current_path}"
    bind \ split-window -h -c "#{pane_current_path}"
    bind | split-window -h -c "#{pane_current_path}"
    bind - split-window -v -c "#{pane_current_path}"
    bind _ split-window -v -c "#{pane_current_path}"

# Mouse mode is off by default
    # <prefix> M : to turn it off
    # <prefix> m : to turn it on
    set -g mouse-utf8 on
    unbind m
    bind m set -g mouse on \; display "Mouse ON"
    bind M set -g mouse off \; display "Mouse OFF"

# pass on focus events to vim inside of tmux
    set -g focus-events on

# List of plugins
    set -g @plugin 'tmux-plugins/tpm'
    # Restore tmux environment
    set -g @plugin 'tmux-plugins/tmux-resurrect'
    # Automatic restore
    set -g @plugin 'tmux-plugins/tmux-continuum'

# Plugin settings
    set -g @continuum-restore 'on'

# Initialize TMUX plugin manager (keep this line at the very bottom of tmux.conf)
    run '~/.tmux/plugins/tpm/tpm'
tmux_1.9_to_2.1.conf
# User key bindings
    # ^C - create new window
    # c - create new window (default key)
    # \ | % - vsplit
    # - _ " - split
    unbind ^C
    bind ^C new-window;
    bind \ split-window -h
    bind | split-window -h
    bind - split-window -v
    bind _ split-window -v

# Mouse mode is off by default
    # <prefix> M : to turn it off
    # <prefix> m : to turn it on
    unbind m
    bind m set -g mode-mouse on \; set -g mouse-resize-pane on \; set -g mouse-select-pane on \; set -g mouse-select-window on \; display "Mouse ON"
    bind M set -g mode-mouse off \; set -g mouse-resize-pane off \; set -g mouse-select-pane off \; set -g mouse-select-window off \; display "Mouse OFF"

# pass on focus events to vim inside of tmux
    set -g focus-events on
verify_tmux_version.sh
#!/bin/bash

verify_tmux_version () {
    tmux_home=~/.tmux
    tmux_version="$(tmux -V | cut -c 6-)"
    
    if [[ $(echo "$tmux_version >= 2.1" | bc) -eq 1 ]] ; then
        tmux source-file "$tmux_home/tmux_2.1_up.conf"
        exit
    elif [[ $(echo "$tmux_version >= 1.9" | bc) -eq 1 ]] ; then
        tmux source-file "$tmux_home/tmux_1.9_to_2.1.conf"
        exit
    else
        tmux source-file "$tmux_home/tmux_1.9_down.conf"
        exit
    fi
}

verify_tmux_version
.tmux.conf
# Overwrite configs depending on version
    run-shell "bash ~/.tmux/verify_tmux_version.sh"