关于nginx sni分流的注意事项
编译nginx stream模块
1 | ./configure --prefix=/usr/share/nginx --conf-path=/etc/nginx/nginx.conf --http-log-path=/var/log/nginx/access.log --error-log-path=/var/log/nginx/error.log --lock-path=/var/lock/nginx.lock --pid-path=/run/nginx.pid --modules-path=/usr/lib/nginx/modules --http-client-body-temp-path=/var/lib/nginx/body --http-fastcgi-temp-path=/var/lib/nginx/fastcgi --http-proxy-temp-path=/var/lib/nginx/proxy --http-scgi-temp-path=/var/lib/nginx/scgi --http-uwsgi-temp-path=/var/lib/nginx/uwsgi --with-debug --with-pcre-jit --with-http_ssl_module --with-http_stub_status_module --with-http_realip_module --with-http_auth_request_module --with-http_v2_module --with-http_dav_module --with-http_slice_module --with-threads --with-http_addition_module --with-http_geoip_module=dynamic --with-http_gunzip_module --with-http_gzip_static_module --with-http_image_filter_module=dynamic --with-http_sub_module --with-http_xslt_module=dynamic --with-stream_ssl_module --with-mail=dynamic --with-mail_ssl_module --with-openssl=/root/download/openssl-1.1.1h --add-module=../ngx-fancyindex-0.5.1 --add-module=../nginx-dav-ext-module --add-module=../headers-more-nginx-module --add-module=../ngx_brotli --with-stream_realip_module --with-stream_ssl_preread_module --with-stream |
下面空上清楚点:
1 | ./configure \ |
注意,原来编译的时候加入动态模块--with-stream=dynamic
,所以要在nginx.conf里加入load_module /usr/lib/nginx/modules/ngx_stream_module.so;
但是我还是不用动态编译,因为编译之后nginx出错。
另外,还要加入--with-stream-realip_module
模块,使之可以传送真实IP
修改nginx.conf文件
加入LOG格式,使/var/log/nginx/access.log里显示真实IP
1 | log_format main '$remote_addr - $remote_user [$time_local] "$request" ' |
这里注意,若需要传递真实IP,需要在server{}里加入以下内容:
1 | listen 443 ssl http2 proxy_protocol; |
加入stream
内容
1 | stream { |
这里注意,这里要加入proxy_protocol on;
这句才能传递真实IP
然后,在/etc/nginx/conf.d/
下加入网站配置文件
比如,web.conf
1 | server { |
然后是web1.xx
1 | server { |
vless.conf
1 | server { |
此时trojan
不需要配置,只需要在config.json里监听即可
配置config.json
config.json
1 | { |
certbot申请证书
1 | certbot certonly --standalone -d vless.xx.xx -d trojan.xx.xx |
注意:由于某软件使用的是nobody账户,所以证书提示没有权限。
先建立一个nobody:nogroup的目录/etc/ssl/xray/vless.xx.xx
1 | install -d -o nobody -g nogroup /etc/ssl/xray/vless.xx.xx |
然后把certbot
生成的证书转移过来
1 | install -m 644 -o nobody -g nogroup /etc/letsencrypt/live/vless.xx.xx/fullchain.pem -t /etc/ssl/xray/vless.xx.xx |
没有解决的问题
目前起码是知道,fail2ban没有正常工作
本博客所有文章除特别声明外,均采用 CC BY-NC-SA 4.0 许可协议。转载请注明来自 3mile的博客!
评论