這兒使用tengine進行安裝, 能夠看之前的博客php
./configure --with-http_v2_module
否則會報錯html
此時安裝的openresty配置http2會報錯 the "http2" parameter requires ngx_http_v2_module
若是已經安裝的ginx, 可使用 nginx -v
查看編譯參數, 而後加上上述參數從新編譯, 以後make
, 不執行 make install
, 而後將編譯後的nginx進行替換現有的.python
cp /usr/local/nginx/sbin/nginx /usr/local/nginx/sbin/nginx.bak cp objs/nginx /usr/local/nginx/sbin/nginx
user root; worker_processes 1; worker_rlimit_nofile 652144; error_log /usr/local/nginx/logs/error.log crit; pid /run/nginx.pid; events { use epoll; multi_accept on; worker_connections 1024; } http { include /usr/local/nginx/conf/mime.types; client_max_body_size 1m; sendfile on; tcp_nopush on; access_log off; keepalive_timeout 60; proxy_ignore_client_abort on; limit_req_zone $binary_remote_addr zone=allips:200m rate=90r/m; upstream vr_server { server 127.0.0.1:18181; keepalive 1000; } include conf.d/*.conf; }
server { listen 80; server_name vr.xxx.cn; location / { root html; index index.html index.htm; } error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } location ~/.well-known { allow all; } return 301 https://$server_name$request_uri; }
注意上面配置中的 location ~/.well-konw
, 這個在使用certbot的時候使用的linux
server { listen 443 ssl http2 default_server; listen [::]:443 ssl http2 default_server; ssl_certificate /etc/letsencrypt/live/vr.xxxxxxxx.cn/fullchain.pem; #生成的密鑰對 #你的ssl證書, 若是第一次,可能還須要自籤一下 ssl_certificate_key /etc/letsencrypt/live/vr.xxxxxxxx.cn/privkey.pem; #生成的密鑰對, 你的ssl key server_name vr.xxxxxxxx.cn; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #使用的協議 ssl_ciphers HIGH:!aNULL:!MD5;#使用的加密算法 root /usr/local/nginx/html; # Add index.php to the list if you are using PHP index index.html index.htm index.nginx-debian.html; location /bronk { proxy_redirect off; proxy_pass http://vr_server; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; } }
我沒試驗這個nginx
server { listen 80; server_name linuxstory.org www.linuxstory.org; return 301 https://$server_name$request_uri; }
system-cmd --zone=public --add-port=80/tcp --permanent system-cmd --zone=public --add-port=443/tcp --permanent
須要本身註冊域名, 而且域名指向本身的服務器, 服務器的443和80端口都開着git
$ yum -y install yum-utils $ yum-config-manager --enable rhui-REGION-rhel-server-extras rhui-REGION-rhel-server-optional
yum install certbot python2-certbot-nginx
cerbot 簽名有兩種方式 一種是 --webroot 一種是 --Standalone 在網上看到的區別是 第一種不須要停如今的服務 第二種須要停掉服務 那好 我須要的是第一種 :)github
而後確認下你要簽名的域名 是否已經指向你本身的服務器了 還有云服務的話 要記得看下安全組 443端口有沒有開 總之就是要確認你的準備工做是沒問題的web
location ~ /.well-known { allow all; }
看到另一種方式, 沒有實驗算法
location ^~ /.well-known/acme-challenge/ { default_type "text/plain"; root /home/wwwroot/linuxstory.org/; } location = /.well-known/acme-challenge/ { return 404; }
certbot certonly --webroot -w /usr/local/nginx/html -d vr.xxx.cn --email xxx@hotmail.com
服務器輸出以下信息, 證實生成正確, 注意其中的目錄地址shell
IMPORTANT NOTES:
- Congratulations! Your certificate and chain have been saved at:
/etc/letsencrypt/live/vr.xxxxxxxx.cn/fullchain.pem
Your key file has been saved at:
/etc/letsencrypt/live/vr.xxxxxxxx.cn/privkey.pem
Your cert will expire on 2019-09-12. To obtain a new or tweaked
version of this certificate in the future, simply run certbot
again. To non-interactively renew all of your certificates, run
"certbot renew"- If you like Certbot, please consider supporting our work by:
Donating to ISRG / Let's Encrypt: https://letsencrypt.org/donate
Donating to EFF: https://eff.org/donate-le
/etc/letsencrypt/live/你的域名/ 下存放的就是密鑰
參照nginx下的v2r@y.conf 文件的配置
crontab -e
以後進行編輯
0 0 15 */3 * /usr/bin/certbot renew # 3,6,9,12月的15號零點進行更新
參考: http簡介及ssl工具
bash <(curl -L -s https://install.direct/go.sh)
此腳本會自動安裝以下文件
/usr/bin/v2r@y/v2r@y:v2r@y 程序;
/usr/bin/v2r@y/v2ctl:v2r@y 工具;
/etc/v2r@y/config.json:配置文件;
/usr/bin/v2r@y/geoip.dat:IP 數據文件
/usr/bin/v2r@y/geosite.dat:域名數據文件 此腳本會配置自動運行腳本。自動運行腳本會在系統重啓以後,自動運行 v2r@y。目前自動運行腳本只支持帶有 Systemd 的系統,以及 Debian / Ubuntu 全系列。
運行腳本位於系統的如下位置:
/etc/systemd/system/v2r@y.service
: Systemd/etc/init.d/v2r@y
: SysVsystemctl start|stop|status|reload|restart|force-reload v2@ray
/etc/v2@ray/config.json
更改配置文件
{ "log" : { "access": "/var/log/v2r@y/access.log", "error": "/var/log/v2r@y/error.log", "loglevel": "warning" }, "inbound": { "port": 10000, //(此端口與nginx配置相關) "listen": "127.0.0.1", "protocol": "vmess", "settings": { "clients": [ { "id": "xxxxxxd1f-687c-4188-9abc-80073a618ca3", //你的UUID, 此ID需與客戶端保持一致 "level": 1, "alterId": 64 //此ID也需與客戶端保持一致 } ] }, "streamSettings":{ "network": "ws", "wsSettings": { "path": "/ray" //與nginx配置相關 } } }, "outbound": { "protocol": "freedom", "settings": {} }, "outboundDetour": [ { "protocol": "blackhole", "settings": {}, "tag": "blocked" } ], "routing": { "strategy": "rules", "settings": { "rules": [ { "type": "field", "ip": [ "0.0.0.0/8", "10.0.0.0/8", "100.64.0.0/10", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.2.0/24", "192.168.0.0/16", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "::1/128", "fc00::/7", "fe80::/10" ], "outboundTag": "blocked" } ] } } }
{ "log": { "loglevel": "warning" }, "inbound": { "port": 1080, "listen": "127.0.0.1", "protocol": "socks", "settings": { "auth": "noauth", "udp": false } }, "inboundDetour": [ { "port": 8123, "listen": "127.0.0.1", "protocol": "http", "settings": {} } ], "outbound": { "protocol": "vmess", "settings": { "vnext": [{ "address": "test.v2r@y.com", // 服務器地址,請修改成你本身的服務器 ip 或域名 "port": 443, // 服務器端口 "users": [{ "id": "4xxxxxxf-687c-4188-9abc-80073a618ca3", //你的UUID, 此ID需與服務端保持一致 "level": 1, "alterId": 64, //此ID也需與客戶端保持一致 "security": "aes-128-gcm" }] }] }, "streamSettings":{ "network": "ws", "security": "tls", "tlsSettings": { "serverName": "test.v2r@y.com" //此域名是你服務器的域名 }, "wsSettings": { "path": "/ray" //與服務器配置及nginx配置相關 } }, "tag": "forgin" }, "outboundDetour": [ { "protocol": "freedom", "settings": {}, "tag": "direct" } ], "routing": { //此路由配置是自動分流, 國內IP和網站直連 "strategy": "rules", "settings": { "domainStrategy": "IPIfNonMatch", "rules": [ { "type": "chinaip", "outboundTag": "direct" }, { "type": "chinasites", "outboundTag": "direct" }, { "type": "field", "ip": [ "0.0.0.0/8", "10.0.0.0/8", "100.64.0.0/10", "127.0.0.0/8", "169.254.0.0/16", "172.16.0.0/12", "192.0.0.0/24", "192.0.2.0/24", "192.168.0.0/16", "198.18.0.0/15", "198.51.100.0/24", "203.0.113.0/24", "::1/128", "fc00::/7", "fe80::/10" ], "outboundTag": "direct" } ] } }, "policy": { "levels": { "0": {"uplinkOnly": 0} } } }
下載客戶端, (下載地址)[https://pan.laod.cc/download/]
v2r@yN
注意uuid 和服務端一致
使用v2r@yX 鏈接不上, 後使用v2r@yU進行鏈接的
wget -N --no-check-certificate "https://raw.githubusercontent.com/chiakge/Linux-NetSpeed/master/tcp.sh" && chmod +x tcp.sh && ./tcp.sh
先選擇2, 重啓後選擇7, 便可
碰到一個異常
rejected v2r@y.com/core/proxy/vmess/encoding: invalid user
是由於v2r@y 的uuid或者服務器時間和本地的不一致
更改服務器時區
timedatectl set-timezone Asia/Shanghai
若是服務器有ipv6, 那麼使用全局模式能夠自動ipv6