zjcqoo 6 سال پیش
والد
کامیت
120d049a50
8فایلهای تغییر یافته به همراه76 افزوده شده و 15 حذف شده
  1. 1 1
      README.md
  2. 12 0
      acme.conf
  3. 0 0
      acme/.well-known/acme-challenge/.gitignore
  4. 1 0
      acme/.well-known/acme-challenge/test.txt
  5. 6 11
      docs/cert-auto.md
  6. 43 0
      log.conf
  7. 9 2
      run.sh
  8. 4 1
      setup-ipset.sh

+ 1 - 1
README.md

@@ -17,7 +17,7 @@ https://zjcqoo.github.io/-----https://www.google.com
 # 安装
 
 ```bash
-curl -O https://raw.githubusercontent.com/EtherDream/jsproxy/master/i.sh && bash i.sh
+curl -O https://raw.githubusercontent.com/EtherDream/jsproxy/master/i.sh | bash
 ```
 
 * 自动安装目前只支持 Linux x64,并且需要 root 权限

+ 12 - 0
acme.conf

@@ -0,0 +1,12 @@
+#
+# 提供 Let's Encrypt 服务验证 challenge
+#
+server {
+  # 从 80 端口重定向过来,因为 jsproxy 用户没有权限开启 80 端口
+  listen                10080;
+  access_log            logs/acme.log combined;
+
+  location /.well-known/acme-challenge/ {
+    root                ../acme;
+  }
+}

+ 0 - 0
acme/.well-known/acme-challenge/.gitignore


+ 1 - 0
acme/.well-known/acme-challenge/test.txt

@@ -0,0 +1 @@
+ok

+ 6 - 11
docs/cert-auto.md

@@ -6,27 +6,23 @@
 iptables -t nat -I PREROUTING 1 -p tcp --dport 80 -j REDIRECT --to-ports 10080
 ```
 
-2.安装 acme.sh
+> 外部访问 http://服务器IP/.well-known/acme-challenge/test.txt 可验证是否正常。返回 `ok` 说明正常。
 
-该脚本依赖 `openssl`,否则无法生成证书(大部分系统默认已安装)
-
-```bash
-yum install -y openssl
-```
-
-安装 acme.sh(无需 root 权限,在 `jsproxy` 用户下安装)
+2.安装 acme.sh(无需 root 权限,在 `jsproxy` 用户下安装)
 
 ```bash
 su - jsproxy
 curl https://raw.githubusercontent.com/Neilpang/acme.sh/master/acme.sh | INSTALLONLINE=1  sh
 ```
 
+> 部分精简系统可能没有 `openssl` 导致运行失败,需提前安装依赖(例如 `yum install -y openssl`)
+
 3.申请证书
 
 ```bash
 # 服务器公网 IP
 ip=$(curl -s https://api.ipify.org)
-domain="$ip.xip.io"
+domain=$ip.xip.io
 
 dist=~/server/cert/$domain
 mkdir -p $dist
@@ -47,7 +43,6 @@ mkdir -p $dist
 
 如果申请失败(例如提示 `rate limit exceeded`),尝试将 `xip.io` 换成 `nip.io`、`sslip.io` 等其他类似的域名。
 
-
 4.生成配置文件:
 
 ```conf
@@ -62,7 +57,7 @@ ssl_certificate_key   cert/$domain/ecc.key;
 
 5.验证
 
-访问 `https://服务器IP.xip.io:8443/`,没出现证书错误即成功(404 等错误不影响)
+访问 `https://服务器IP.xip.io:8443/`,没出现证书错误即成功。
 
 6.关闭 80 端口转发
 

+ 43 - 0
log.conf

@@ -0,0 +1,43 @@
+#
+# 日志格式定义
+# https://nginx.org/en/docs/http/ngx_http_log_module.html
+#
+# 分隔: tab (\t)
+# 前缀: 格式版本。格式变化时递增,方便解析
+# 备注:
+# origin_id
+#   请求源的别名,参考 allowed-sites.conf
+# ver
+#   前端配置的版本,定义于 www/conf.js
+# remote_addr
+#   用户 IP,目前未考虑 XFF
+# level
+#   实验中。记录切换状态(首次请求为 1。切换失败再次请求为 0,表示不接受切换)
+# switched
+#   实验中。记录是否切换到廉价节点(未切换则为空,有切换则记录资源体积大小)
+# bodyhash
+#   返回内容的 SHA256,用于统计重复内容
+# upstream_http_access_control_allow_origin
+#   统计支持 cors 的站点,用于加入直接列表
+# ref
+#   请求 referer,不包括 `https://example.com/-----` 部分
+# mode
+#   前端 request.mode 属性
+# type
+#   前端 request.destination 属性
+#
+log_format              log_proxy escape=none
+  '02	'
+  '$time_iso8601	$_origin_id	$_ver	$remote_addr	'
+  '$_level	$_switched	$upstream_cache_status	$request_time	'
+  '$request_length	$bytes_sent	'
+  '$request_method	$_url	$status	$_bodyhash	$upstream_http_access_control_allow_origin	'
+  '$http_user_agent	$_ref	$_mode	$_type'
+;
+
+log_format              log_www escape=none
+  '01	'
+  '$time_iso8601	$remote_addr	$request_time	'
+  '$request_method	$uri	$http_host	$status	'
+  '$http_user_agent'
+;

+ 9 - 2
run.sh

@@ -1,8 +1,15 @@
-NGX_BIN=$HOME/openresty/nginx/sbin/nginx
+#
+# 该脚本封装 nginx 调用,可在任意位置执行
+#
+# 启动:./run.sh 
+# 重启:./run.sh -s reload
+# 关闭:./run.sh -s quit 
+# 
+NGX_BIN=~/openresty/nginx/sbin/nginx
 CUR_DIR=$(cd `dirname $0` && pwd)
 
 if [ $1 ]; then
   PARAM="-s $1"
 fi
 
-$NGX_BIN -c $CUR_DIR/nginx.conf -p $CUR_DIR/nginx $PARAM
+$NGX_BIN -c $CUR_DIR/nginx.conf -p $CUR_DIR/nginx $PARAM

+ 4 - 1
setup-ipset.sh

@@ -1,4 +1,7 @@
-# 需要 root 运行
+#
+# 该脚本用于禁止 jsporxy 用户访问内网(针对 TCP)
+# 需要 root 权限运行,依赖 ipset 命令
+#
 ipset create ngx-ban-dstip hash:net
 
 # 该策略对 jsproxy 用户的所有程序都生效