This commit is contained in:
light 2017-09-01 16:13:48 +08:00
parent 3f9837983e
commit c744b83eae
10 changed files with 344 additions and 2 deletions

84
gfw/shadowsockes.md Normal file
View File

@ -0,0 +1,84 @@
# 使用shadowsockes
> https://yq.aliyun.com/articles/137280?commentId=11711
> https://github.com/shadowsocks/
## install
``` bash
sudo apt update
sudo apt upgrade
sudo pip install shadowsocks
```
## 服务端配置
```
{
"server":"0.0.0.0",
"server_port":××,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"×××××",
"timeout":300,
"method":"rc4-md5"
}
ssserver -c /etc/shadowsocks.json -d start
ssserver -c /etc/shadowsocks.json -d stop
```
## ubuntu客户端配置
1. chrome 安装SwitchyOmega
2. 本地安装shadowsocks
3. 配置本地连接到服务器
```
{
"server":"serverIP",
"server_port":**,
"local_address": "127.0.0.1",
"local_port":1080,
"password":"*****",
"timeout":300,
"method":"rc4-md5",
"fast_open": true,
"workers": 1
}
```
4. 运行和停止服务
> sudo sslocal -c /etc/shadowsocks.json -d start
> sudo sslocal -c /etc/shadowsocks.json -d stop
5. SwitchyOmega 设置socks5 连接到127.0.0.1 1080
## haproxy
```
global
ulimit-n 51200
defaults
log global
mode tcp
option dontlognull
timeout connect 1000ms
timeout client 150000ms
timeout server 150000ms
frontend 110-in
bind *:110
default_backend 110-out
backend 110-out
server server1 ******:3801 maxconn 20480
```
haproxy -f /etc/haproxy/haproxy.cfg

115
git/gitlab_nginx.md Normal file
View File

@ -0,0 +1,115 @@
# gitlab 使用本地nginx
- refer to https://sanwen8.cn/p/57br7vb.html
- refer to http://www.cnblogs.com/lixiuran/p/6761299.html
## 修改gitlab配置文件
- 备份
> cp /opt/gitlab/service/nginx/run /opt/gitlab/service/nginx/run_copy
- 修改
``` bash
#源内容
#!/bin/sh
exec 2>&1
cd /var/opt/gitlab/nginxexec chpst -P /opt/gitlab/embedded/sbin/nginx -p
/var/opt/gitlab/nginx
#新内容
#!/bin/sh
exec 2>&1
cd /usr/local/nginx
exec chpst -P /usr/local/nginx/sbin/nginx -p
/usr/local/nginx
```
## nginx 增加虚拟主机配置
``` bash
# gitlab socket 文件地址
upstream gitlab {
# 7.x 版本在此位置
# server unix:/var/opt/gitlab/gitlab-rails/tmp/sockets/gitlab.socket;
# 8.0 位置
server unix://var/opt/gitlab/gitlab-rails/sockets/gitlab.socket;
}
server {
listen *:8081;
server_name gitlab.liaohuqiu.com; # 请修改为你的域名
server_tokens off; # don't show the version number, a security best practice
root /opt/gitlab/embedded/service/gitlab-rails/public;
# Increase this if you want to upload large attachments
# Or if you want to accept large git objects over http
client_max_body_size 250m;
# individual nginx logs for this gitlab vhost
access_log /var/log/gitlab/nginx/gitlab_access.log;
error_log /var/log/gitlab/nginx/gitlab_error.log;
location / {
# serve static files from defined root folder;.
# @gitlab is a named location for the upstream fallback, see below
try_files $uri $uri/index.html $uri.html @gitlab;
}
# if a file, which is not found in the root folder is requested,
# then the proxy pass the request to the upsteam (gitlab unicorn)
location @gitlab {
# If you use https make sure you disable gzip compression
# to be safe against BREACH attack
proxy_read_timeout 300; # Some requests take more than 30 seconds.
proxy_connect_timeout 300; # Some requests take more than 30 seconds.
proxy_redirect off;
proxy_set_header X-Forwarded-Proto $scheme;
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-Frame-Options SAMEORIGIN;
proxy_pass http://gitlab;
}
# Enable gzip compression as per rails guide: http://guides.rubyonrails.org/asset_pipeline.html#gzip-compression
# WARNING: If you are using relative urls do remove the block below
# See config/application.rb under "Relative url support" for the list of
# other files that need to be changed for relative url support
location ~ ^/(assets)/ {
root /opt/gitlab/embedded/service/gitlab-rails/public;
# gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
error_page 502 /502.html;
}
```
## 禁用自带 nginx
``` bash
vim /etc/gitlab/gitlab.rb
# 修改
nginx['enable'] = false
```
## 重启 nginx, 重启gitlab
``` bash
sudo /usr/local/nginx/sbin/nginx -s reload
sudo gitlab-ctl reconfigure
```
## 权限配置
访问会报502。原本是 nginx 用户无法访问gitlab用户的 socket 文件,用户权限配置,因人而异。粗暴地:
> sudo chmod -R o+x /var/opt/gitlab/gitlab-rails

View File

@ -1,7 +1,7 @@
# ssh key 生成和使用
## 生成 ssh key
git config --global user.name 'light'
git config --global user.name '1870499383@qq.com'
git config --global user.email '1870499383@qq.com'
ssh-keygen -t rsa -C '1870499383@qq.com'
注:连按三下回车,选择默认即可

15
go/安装go1.4.md Normal file
View File

@ -0,0 +1,15 @@
# 安装go1.4
``` bash
wget https://storage.googleapis.com/golang/go1.4.2.linux-amd64.tar.gz
tar -zxvf go1.4.2.linux-amd64.tar.gz -C /srv/software/go-bootstrap/
export GOROOT="/srv/software/go-bootstrap/"
export GOROOT_BOOTSTRAP="/srv/software/go-bootstrap/"
cd /srv/software/go-bootstrap/src/
./all.bash
```

44
ngrok/ngrok.md Normal file
View File

@ -0,0 +1,44 @@
# 如何搭建ngrok服务器做内网穿透
> https://www.qcloud.com/community/article/915303001489140121
> http://blog.csdn.net/kenlong/article/details/52880210
``` bash
sudo apt-get install build-essential golang mercurial
git clone https://github.com/tutumcloud/ngrok.git ngrok
cd ngrok
export NGROK_DOMAIN="ngrok.hellolight.me"
openssl genrsa -out base.key 2048
openssl req -new -x509 -nodes -key base.key -days 10000 -subj "/CN=$NGROK_DOMAIN" -out base.pem
openssl genrsa -out server.key 2048
openssl req -new -key server.key -subj "/CN=$NGROK_DOMAIN" -out server.csr
openssl x509 -req -in server.csr -CA base.pem -CAkey base.key -CAcreateserial -days 10000 -out server.crt
cp base.pem assets/client/tls/ngrokroot.crt
sudo make release-server release-client
```
``` bash
sudo ./bin/ngrokd -tlsKey=server.key -tlsCrt=server.crt -domain="ngrok.hellolight.me" -httpAddr=":8081" -httpsAddr=":8082"
```
``` bash
server_addr: "ngrok.hellolight.me:4443"
trust_host_root_certs: false
```
./ngrok -subdomain pub -proto=http -config=ngrok.cfg 8000
./ngrok -subdomain pub -proto=http -config=ngrok.cfg 22

View File

@ -7,7 +7,8 @@
``` bash
sudo apt install nodejs
sudo apt install npm
sudo npm install npm@latest -g
npm install npm@latest -g
sudo npm install n@latest -g
sudo n stable
node -v
npm -v

46
python/ReformFileName.py Normal file
View File

@ -0,0 +1,46 @@
# coding=utf-8
"""
light
20170715
批量修改文件名
"""
import os
import re
class ReformFileName(object):
def __init__(self):
self.renames("/home/light/PycharmProjects/fetchcore/src/fetchcore/")
def renames(self, dire):
if not os.path.isdir(dire):
raise Exception("dire error")
for item in os.listdir(dire):
path = os.path.join(dire, item)
if os.path.isdir(path):
self.renames(path)
elif os.path.isfile(path):
res = self.rules(item)
if res:
self.rename(dire, item, res)
def rules(self, name):
temp = re.findall(r'(.*).pyc_dis$', name)
if temp:
new_name = temp[0] + '.py'
return new_name
else:
return False
def rename(self, path, name, new_name):
if os.path.exists(os.path.join(path, new_name)):
pass
os.remove(os.path.join(path, name))
# raise Exception(' %s exist' % os.path.join(path, new_name))
else:
os.rename(os.path.join(path, name), os.path.join(path, new_name))
# os.rename()
if __name__ == "__main__":
temp = ReformFileName()

21
python/uncompyle2.md Normal file
View File

@ -0,0 +1,21 @@
# pyc 反编译
- 环境: ubuntun14.04
## 安装
```bash
sudo pip install uncompyle2
```
## 使用
``` bash
# 单独反编译某文件
uncompyle2 -o /***/***.py /***/***.pyc
# 批量反编译文件
uncompyle2 -ro /***/ /***/
```

1
ubuntu/nmap.md Normal file
View File

@ -0,0 +1 @@
nmap -v -sP 192.168.1.0/24

15
ubuntu/screen.md Normal file
View File

@ -0,0 +1,15 @@
``` bash
screen -ls
screen -r name
screen -d name
screen -dmS name ngrok start client ssh server
screen -dmS ngrok ngrok start client ssh server
screen -dmS sslocal sslocal -c /etc/shadowsocks.json -d start
screen -dmS test ngrokStart -d
sudo ./bin/ngrokd -tlsKey=server.key -tlsCrt=server.crt -domain="ngrok.hellolight.me" -httpAddr=":8081" -httpsAddr=":8082"
```