全球主机交流论坛

 找回密码
 注册

QQ登录

只需一步,快速开始

IP归属甄别会员请立即修改密码
查看: 5715|回复: 38
打印 上一主题 下一主题

xray配置谁能给一份,主要是nginx的回落,搞不定啊

[复制链接]
跳转到指定楼层
1#
发表于 2023-2-15 19:09:10 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式
本帖最后由 坏坏 于 2023-2-18 14:12 编辑

xray配置谁能给一份,主要是nginx的回落,搞不定啊





对不起,,,楼下所有大哥大叔,大爷,祖宗们

我自己挖了一个大坑

我一直修改的是V2的配置,,,,用的是Xray的程序

因为是用xshell 的快捷命令修改,,,我自己没有仔细看,也没有去思考,,想当然认为配置都是一个路径
结果一直修改的是v2的配置文件................

深刻的检讨自己的粗心大意

推荐
发表于 2023-2-17 12:59:02 | 只看该作者

客气了,现在xray这思路就是尽量简洁,一个前置接管443可以all in one处理各种fallback后端监听,并且和nginx互不干扰,你可以看看这个all in one 配置示例,自行增删就可以了,fallback本身也可以一级级嵌套,和这演示的扁平化分流都行的:
https://github.com/XTLS/Xray-examples/tree/main/All-in-One-fallbacks-Nginx
推荐
发表于 2023-2-17 12:38:59 | 只看该作者
nginx前置分流, xray后置的。
这是xray的配置
  1. {
  2.     "log": {
  3.         "loglevel": "warning",
  4.         "access": "/var/log/xray/access.log",
  5.         "error": "/var/log/xray/error.log"
  6.     },
  7.     "dns": {
  8.         "servers": [
  9.             "https+local://8.8.8.8/dns-query"
  10.         ]
  11.     },
  12.     "routing": {
  13.         "domainStrategy": "IPIfNonMatch",
  14.         "domainMatcher": "mph",
  15.         "rules": [
  16.             // rules 自己配置
  17.         ]
  18.     },
  19.     "inbounds": [
  20.         {
  21.             "listen": "127.0.0.1",
  22.             "port": 41256, // 端口自己定义, 跟 nginx 配置中留存的端口一致
  23.             "protocol": "vless",
  24.             "settings": {
  25.                 "clients": [
  26.                     {
  27.                         "id": "xxxxxxxxxxxxx",
  28.                         "level": 0,
  29.                         "email": "",
  30.                         "flow": "xtls-rprx-vision"
  31.                     }
  32.                 ],
  33.                 "decryption": "none"
  34.             },
  35.             "sniffing": {
  36.                 "enabled": true,
  37.                 "destOverride": [
  38.                     "http",
  39.                     "tls"
  40.                 ]
  41.             },
  42.             "streamSettings": {
  43.                 "network": "tcp",
  44.                 "security": "tls",
  45.                 "tlsSettings": {
  46.                     "rejectUnknownSni": true,
  47.                     "certificates": [
  48.                         {
  49.                             "ocspStapling": 3600,
  50.                             "oneTimeLoading": false,
  51.                             "usage": "encipherment",
  52.                             "certificateFile": "/usr/ssl/chain.pem",         // 证书地址
  53.                             "keyFile": "/usr/ssl/key.pem"                // key地址
  54.                         }
  55.                     ]
  56.                 },
  57.                 "tcpSettings":{
  58.                     "acceptProxyProtocol": true,
  59.                     "header": {
  60.                         "type": "none"
  61.                       }
  62.                 }
  63.             }
  64.         }
  65.     ],
  66.     "outbounds": [
  67.         {
  68.             "protocol": "freedom",
  69.             "tag": "direct",
  70.             "settings": {
  71.                 "domainStrategy": "UseIP"
  72.             }
  73.         },
  74.         {
  75.             "protocol": "blackhole",
  76.             "tag": "block",
  77.             "settings": {
  78.                 "response": {
  79.                     "type": "http"
  80.                 }
  81.             }
  82.         }
  83.     ]
  84. }
复制代码


这是nginx的配置
  1. user www-data;
  2. worker_processes auto;
  3. pid /run/nginx.pid;
  4. include /etc/nginx/modules-enabled/*.conf;

  5. events {
  6.     worker_connections 768;
  7.     # multi_accept on;
  8. }

  9. # tcp 四层分流
  10. stream {

  11.     log_format log_stream '$remote_addr [$time_local] $protocol '
  12.         '[$ssl_preread_server_name] [$ssl_preread_alpn_protocols] '
  13.         '$status $bytes_sent $bytes_received $session_time';

  14.     error_log   /var/log/nginx/pserver/error.log info;                // 注意,请创建 /var/log/nginx/pserver/文件夹
  15.     access_log  /var/log/nginx/pserver/access.log log_stream;

  16.     map $ssl_preread_server_name $stream_map {
  17.         # 服务站点
  18.         default homepage;                                // 除 xray 域名,其他的域名分流到 homepage
  19.         # 伪装代理
  20.         xray.example.com xray_core;                // xray.example.com : xray对应的域名,分流到 xray_core
  21.     }
  22.     # 服务站点
  23.     upstream homepage {
  24.         server 127.0.0.1:41255;                        // 41255端口, nginx 网页监听 端口
  25.     }
  26.     # 伪装代理
  27.     upstream xray_core {
  28.         server 127.0.0.1:41256;                           // 41256端口, 前面 xray 监听的端口
  29.     }                                                                                                         
  30.     server {
  31.         listen 443;
  32.         proxy_pass $stream_map;
  33.         proxy_protocol on;
  34.         ssl_preread on;
  35.     }
  36. }

  37. http {

  38.     ##
  39.     # Basic Settings
  40.     ##

  41.     sendfile on;
  42.     tcp_nopush on;
  43.     types_hash_max_size 2048;
  44.     # server_tokens off;

  45.     # server_names_hash_bucket_size 64;
  46.     # server_name_in_redirect off;

  47.     include /etc/nginx/mime.types;
  48.     default_type application/octet-stream;

  49.     ##
  50.     # Logging Settings
  51.     ##
  52.                      
  53.     log_format  main  '$proxy_protocol_addr - $remote_user [$time_local] "$request" '
  54.                       '$status $body_bytes_sent "$http_referer" '
  55.                       '"$http_user_agent" "$http_x_forwarded_for"';

  56.     access_log /var/log/nginx/access.log main;
  57.     error_log /var/log/nginx/error.log;

  58.     ##
  59.     # SSL Settings
  60.     ##
  61.     ssl_certificate /usr/ssl/chain.pem;     // ssl证书地址
  62.     ssl_certificate_key /usr/ssl/key.pem;     // ssl key 地址

  63.     ssl_session_timeout 1d;
  64.     ssl_session_cache shared:MozSSL:10m;
  65.     ssl_session_tickets off;
  66.     ssl_protocols TLSv1.3;
  67.     ssl_prefer_server_ciphers off;
  68.     add_header Strict-Transport-Security "max-age=63072000" always;

  69.     # OCSP stapling
  70.     ssl_stapling on;
  71.     ssl_stapling_verify on;

  72.     ##
  73.     # Gzip Settings
  74.     ##

  75.     gzip on;

  76.     gzip_vary on;
  77.     gzip_proxied any;
  78.     gzip_min_length 1k;
  79.     gzip_comp_level 2;
  80.     gzip_buffers 16 8k;
  81.     gzip_http_version 1.1;
  82.     gzip_disable "MSIE [1-6]\.";
  83.     gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

  84.     ##
  85.     # Virtual Host Configs
  86.     ##

  87.     include /etc/nginx/conf.d/*.conf;
  88.     include /etc/nginx/sites-enabled/*;
  89.   
  90.     # proxy_protocol协议将访问IP修改为客户端IP
  91.     set_real_ip_from 127.0.0.1;
  92.     real_ip_header proxy_protocol;

  93.     # 端口转发设置
  94.     absolute_redirect on;
  95.     port_in_redirect off;
  96.     server_name_in_redirect off;

  97.     server {
  98.         listen 80;
  99.         server_name example.com;                // 注意修改域名
  100.         return 301 https://$host$request_uri;                // 强制重定向到 https
  101.     }

  102.     server {
  103.         listen 127.0.0.1:41255 ssl http2 proxy_protocol;
  104.         server_name aaa.example.com;  // 网站域名,注意修改域名
  105.        
  106.         // 自行配置网站

  107.     }

  108.     server {  // 如果有域名分流,请这样配置。 如果没有, 可以删除
  109.         listen 127.0.0.1:41255 ssl http2 proxy_protocol;
  110.         server_name bbb.example.com;        // 分流的网站域名: bbb.example.com


  111.         // 自行配置网站        
  112.     }
  113.    
  114. }


  115. #mail {
  116. #        # See sample authentication script at:
  117. #        # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
  118. #
  119. #        # auth_http localhost/auth.php;
  120. #        # pop3_capabilities "TOP" "USER";
  121. #        # imap_capabilities "IMAP4rev1" "UIDPLUS";
  122. #
  123. #        server {
  124. #                listen     localhost:110;
  125. #                protocol   pop3;
  126. #                proxy      on;
  127. #        }
  128. #
  129. #        server {
  130. #                listen     localhost:143;
  131. #                protocol   imap;
  132. #                proxy      on;
  133. #        }
  134. #}
复制代码
2#
发表于 2023-2-15 19:12:10 | 只看该作者
为什么不用一键呢
3#
发表于 2023-2-15 19:12:32 | 只看该作者
看不懂你们搞的这些,花里胡哨的,我tcp+http就是干
4#
发表于 2023-2-15 19:25:13 | 只看该作者
Nginx巨吃性能,该封还封没吊用。过来人劝你没必要。我之前部署的Nginx反而慢了,也封过端口
5#
发表于 2023-2-15 19:33:59 | 只看该作者
除非你要用Windows搭梯子,不然一键脚本或者各种面板直接搞定更快
6#
发表于 2023-2-15 19:34:25 | 只看该作者
daima.eu.org
7#
发表于 2023-2-15 19:34:25 | 只看该作者
nauya 发表于 2023-2-15 19:25
Nginx巨吃性能,该封还封没吊用。过来人劝你没必要。我之前部署的Nginx反而慢了,也封过端口 ...

就是
8#
发表于 2023-2-15 19:41:07 来自手机 | 只看该作者
https://github.com/chika0801/Xray-examples/blob/main/VLESS-TCP-XTLS-Vision/config_server_with_fallbacks.json
9#
发表于 2023-2-15 21:31:43 | 只看该作者
回落没什么卵用,我没有回落照样好好的
10#
发表于 2023-2-15 22:05:48 | 只看该作者
fallback是填的web服务器地址,你的nginx都没监听8888,回落什么?
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2026-1-14 15:19 , Processed in 0.066220 second(s), 11 queries , Gzip On, MemCache On.

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

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