CeraNetworks网络延迟测速工具IP归属甄别会员请立即修改密码
查看: 1590|回复: 51
打印 上一主题 下一主题

[翻译] Nginx + 5hadowsocs-libev + v2ray-plugin

  [复制链接]

4

主题

139

回帖

5033

积分

论坛元老

Rank: 8Rank: 8

积分
5033
跳转到指定楼层
1#
发表于 2020-2-25 19:49:05 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 Renzheng 于 2020-2-27 11:48 编辑

错误原因

始末:通过 nginx 分流博客网站和小飞机的流量,使得 博客 和 v2ray-plugin 插件共存,也同时可以更好的伪装小飞机的流量,即 Shadowsocks over websocket (HTTPS) 。博客是基于 LNMP.org 搭建的。

以下错误原因在于 nginx 的配件文件的这一行:

  1. include rewrite/typecho.conf;
复制代码


重写 typecho 会使得分流失败。

  1. root@sg:/usr/local/nginx/conf/vhost# cat ../rewrite/typecho.conf
  2.     if (!-e $request_filename) {
  3.         rewrite ^(.*)$ /index.php$1 last;
  4.     }
复制代码


但是只需要在网站根目录新建一个文件夹就好:

  1. # image 为 SS 分流的 path
  2. mkdir /home/wwwroot/example.com/image
复制代码






以下是原帖

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

今天尝试使用 Nginx 反向代理 shadowsocks-libev + v2ray-plugin 实现分流,使得网站和 v2ray-plugin 共存,但是好像配置失败了,一直连不上。在这里问问各位大佬到底是哪里出了问题?谢谢

无需推荐 v2ray 了, 这和 v2ray 的 WebSocket+TLS+Web 如出一辙。机场也就别来打广告了。



shadowsocks-libev 配置文件

  1. root@iZt4ngiff6xe6fa04n7ew4Z:~# cat /etc/shadowsocks-libev/config.json
  2. {
  3.     "server":"0.0.0.0",
  4.     "server_port":8443,
  5.     "password":"password",
  6.     "timeout":300,
  7.     "user":"nobody",
  8.     "method":"chacha20-ietf-poly1305",
  9.     "fast_open":false,
  10.     "nameserver":"8.8.8.8",
  11.     "mode":"tcp_and_udp",
  12.     "plugin":"v2ray-plugin",
  13.     "plugin_opts":"server;path=/image;loglevel=none"
  14. }
复制代码


nginx 配置文件,域名已经使用 example.com 替代了。

  1. root@iZt4ngiff6xe6fa04n7ew4Z:~# cat /usr/local/nginx/conf/vhost/example.com.conf
  2. server
  3.     {
  4.         listen 80;
  5.         #listen [::]:80;
  6.         server_name example.com;
  7.    
  8.         return 301 https://example.com$request_uri;
  9.     }

  10. server
  11.     {
  12.         listen 443 ssl http2;
  13.         #listen [::]:443 ssl http2;
  14.         server_name example.com ;
  15.         index index.html index.htm index.php default.html default.htm default.php;
  16.         root  /home/wwwroot/example.com;

  17.         ssl_certificate /usr/local/nginx/conf/ssl/example.com/fullchain.pem;
  18.         ssl_certificate_key /usr/local/nginx/conf/ssl/example.com/private.key;
  19.         ssl_session_timeout 5m;
  20.         ssl_protocols TLSv1 TLSv1.1 TLSv1.2 TLSv1.3;
  21.         ssl_prefer_server_ciphers on;
  22.         ssl_ciphers "TLS13-AES-256-GCM-SHA384:TLS13-CHACHA20-POLY1305-SHA256:TLS13-AES-128-GCM-SHA256:TLS13-AES-128-CCM-8-SHA256:TLS13-AES-128-CCM-SHA256:EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5";
  23.         ssl_session_cache builtin:1000 shared:SSL:10m;
  24.         # openssl dhparam -out /usr/local/nginx/conf/ssl/dhparam.pem 2048
  25.         ssl_dhparam /usr/local/nginx/conf/ssl/dhparam.pem;

  26.         include rewrite/typecho.conf;
  27.         #error_page   404   /404.html;

  28.         # Deny access to PHP files in specific directory
  29.         #location ~ /(wp-content|uploads|wp-includes|images)/.*\.php$ { deny all; }

  30.         include enable-php-pathinfo.conf;

  31.         location /image {
  32.             proxy_redirect off;
  33.             proxy_http_version 1.1;
  34.             proxy_pass http://127.0.0.1:8443;
  35.             proxy_set_header Host $http_host;
  36.             proxy_set_header Upgrade $http_upgrade;
  37.             proxy_set_header Connection "upgrade";
  38.         }

  39.         location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  40.         {
  41.             expires      30d;
  42.         }

  43.         location ~ .*\.(js|css)?$
  44.         {
  45.             expires      12h;
  46.         }

  47.         location ~ /.well-known {
  48.             allow all;
  49.         }

  50.         location ~ /\.
  51.         {
  52.             deny all;
  53.         }

  54.         access_log  /home/wwwlogs/example.com.log;
  55.     }
复制代码


本地客户端配置



shadowsocks-libev status



example.com 访问日志

  1. cat /home/wwwlogs/example.com.log
复制代码


4

主题

139

回帖

5033

积分

论坛元老

Rank: 8Rank: 8

积分
5033
来自 2#
 楼主| 发表于 2020-2-25 19:50:57 | 只看该作者
本帖最后由 Renzheng 于 2020-2-26 23:00 编辑

如果把 Nginx 关闭,将 shadowsocks 改用 443端口,即使用如下配置是可以使用的。
  1. {
  2.     "server":"0.0.0.0",
  3.     "server_port":443,
  4.     "password":"passsword",
  5.     "timeout":300,
  6.     "user":"nobody",
  7.     "method":"chacha20-ietf-poly1305",
  8.     "fast_open":false,
  9.     "nameserver":"8.8.8.8",
  10.     "mode":"tcp_and_udp",
  11.     "plugin": "v2ray-plugin",
  12.     "plugin_opts": "server;tls;host=example.com;cert=/usr/local/nginx/conf/ssl/example.com/fullchain.cer;key=/usr/local/nginx/conf/ssl/example.com/example.com.key"
  13. }
复制代码


这样会使得 shadowsocks 占用 nginx 端口,无法和 nginx 同时运行。

828

主题

1万

回帖

2万

积分

论坛神仙

Rank: 9Rank: 9Rank: 9

积分
22454
推荐
发表于 2020-2-25 19:53:05 | 只看该作者
你要搭建这么复杂的做什么?签名省心吧

4

主题

139

回帖

5033

积分

论坛元老

Rank: 8Rank: 8

积分
5033
推荐
 楼主| 发表于 2020-2-25 22:32:48 | 只看该作者
Luna 发表于 2020-2-25 21:59
其实我不建议用ss+v2ray插件的方式,因为看占用就会知道这样会比v2ray更耗资源,而且速度上确实会有差距的
...

还坚持使用 shadowsocks 是因为 shadowsocks 相对来说成熟。客户端也都比较好用。

34

主题

1277

回帖

1万

积分

论坛元老

Rank: 8Rank: 8

积分
12481
推荐
发表于 2020-2-25 19:57:29 | 只看该作者
省省吧,你这样折腾来折腾去还不如直接上原版V2? 大佬教程也多的是。。。

点评

这和 v2ray 的配置是差不多的,都是使用 nginx 分流。  发表于 2020-2-25 19:58

21

主题

226

回帖

1586

积分

金牌会员

Rank: 6Rank: 6

积分
1586
推荐
发表于 2020-3-21 18:41:18 | 只看该作者
Renzheng 发表于 2020-2-25 22:32
还坚持使用 shadowsocks 是因为 shadowsocks 相对来说成熟。客户端也都比较好用。 ...

跟楼主观点高度一致,客户端好用太重要
祝大家身体健康,生活如意

5

主题

142

回帖

7651

积分

论坛元老

Rank: 8Rank: 8

积分
7651
推荐
发表于 2020-2-26 00:05:42 | 只看该作者
Luna 发表于 2020-2-25 21:59
其实我不建议用ss+v2ray插件的方式,因为看占用就会知道这样会比v2ray更耗资源,而且速度上确实会有差距的
...

不知道为啥,我同一时间用ss+v2插件比单纯v2 wss更快更稳定,可能和地区有关

4

主题

139

回帖

5033

积分

论坛元老

Rank: 8Rank: 8

积分
5033
4#
 楼主| 发表于 2020-2-25 19:54:46 | 只看该作者
三不 发表于 2020-2-25 19:53
你要搭建这么复杂的做什么?签名省心吧

这样更加安全呐

462

主题

1万

回帖

2万

积分

论坛神仙

Rank: 9Rank: 9Rank: 9

积分
20821
QQ
5#
发表于 2020-2-25 19:56:14 | 只看该作者
三不 发表于 2020-2-25 19:53
你要搭建这么复杂的做什么?签名省心吧

机场是自己的挂了,应急用  但是我已经用机场已经一个月了  还真的不错

9

主题

330

回帖

1万

积分

论坛元老

Rank: 8Rank: 8

积分
10633
7#
发表于 2020-2-25 19:58:22 | 只看该作者
为毛不直接上V2

4

主题

139

回帖

5033

积分

论坛元老

Rank: 8Rank: 8

积分
5033
8#
 楼主| 发表于 2020-2-25 20:00:03 | 只看该作者

因为 v2ray 的WebSocket+TLS+Web 也是这么配置的

55

主题

878

回帖

8633

积分

论坛元老

Rank: 8Rank: 8

积分
8633
9#
发表于 2020-2-25 20:04:10 | 只看该作者

"server":"127.0.0.1",
试试

55

主题

851

回帖

196

积分

禁止访问

积分
196
QQ
10#
发表于 2020-2-25 20:05:38 来自手机 | 只看该作者
提示: 作者被禁止或删除 内容自动屏蔽
抱歉,管理员设置了本版块发表于 -30 天以前的主题自动关闭,不再接受新回复

本版积分规则

举报|Archiver|手机版|小黑屋|全球主机交流论坛

GMT+8, 2025-12-24 03:09 , Processed in 0.300943 second(s), 26 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表