FranzKafkaYu / x-ui

Lightweight Xray panel with multi-protocol and multi-user on the same port,supports English language and Telegram bot. Easy to use and easy to manage.
GNU General Public License v3.0
8.05k stars 1.64k forks source link

入站配置,希望增加用户的代理访问日志配置选项 #466

Closed wuai1024 closed 1 year ago

wuai1024 commented 1 year ago

Welcome

Description of the problem,screencshot would be good

image

目前增加入站规则后,没有地方能查询到代理的日志。

我是全局旁路由代理的,有些时候需要根据日志查看下 把一些域名加入 【直连】

Version of x-ui

```console $ x-ui version # Paste output here ``` 最新版

x-ui log or xray log

```console # paste log here ```
FranzKafkaYu commented 1 year ago

目前你可以在面板设置->Xray相关设置内配置模板以启用xray日志,如下所示:

"log": {
    "access": "/usr/local/x-ui/bin/access.log",
    "error": "/usr/local/x-ui/bin/error.log",
    "loglevel": " debug",
    "dnsLog": true
 },  

完整配置参考如下所示:

{
"log": {
    "access": "/usr/local/x-ui/bin/access.log",
    "error": "/usr/local/x-ui/bin/error.log",
    "loglevel": " debug",
    "dnsLog": true
 },
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
 "dns": {
      "servers": [
      "127.0.0.1"
    ]
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blocked"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockedByIp"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockedByDomain"
    }
  ],
  "policy": {
    "levels": {
      "0": {
        "handshake": 10,
        "connIdle": 100,
        "uplinkOnly": 2,
        "downlinkOnly": 3,
        "statsUserUplink": true,
        "statsUserDownlink": true,
        "bufferSize": 10240
      }
    },
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "domainMatcher": "hybrid",
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      },
      {
        "ip": [
          "geoip:cn"
        ],
        "outboundTag": "blockedByIp",
        "type": "field"
      },
      {
        "type": "field",
        "domain": [
          "geosite:category-ads-all",
          "geosite:cn",
          "geosite:tld-cn",
          "geosite:private",
          "geosite:category-games@cn"
        ],
        "outboundTag": "blockedByDomain"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      }
    ]
  },
  "stats": {}
}

保存配置后重启面板,服务器内使用如下命令实时查看日志:

tail -f /usr/local/x-ui/bin/access.log | grep -v 127.0.0.1    
wuai1024 commented 1 year ago

目前你可以在面板设置->Xray相关设置内配置模板以启用xray日志,如下所示:

"log": {
    "access": "/usr/local/x-ui/bin/access.log",
    "error": "/usr/local/x-ui/bin/error.log",
    "loglevel": " debug",
    "dnsLog": true
 },  

完整配置参考如下所示:

{
"log": {
    "access": "/usr/local/x-ui/bin/access.log",
    "error": "/usr/local/x-ui/bin/error.log",
    "loglevel": " debug",
    "dnsLog": true
 },
  "api": {
    "services": [
      "HandlerService",
      "LoggerService",
      "StatsService"
    ],
    "tag": "api"
  },
 "dns": {
      "servers": [
      "127.0.0.1"
    ]
  },
  "inbounds": [
    {
      "listen": "127.0.0.1",
      "port": 62789,
      "protocol": "dokodemo-door",
      "settings": {
        "address": "127.0.0.1"
      },
      "tag": "api"
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blocked"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockedByIp"
    },
    {
      "protocol": "blackhole",
      "settings": {
        "response": {
          "type": "http"
        }
      },
      "tag": "blockedByDomain"
    }
  ],
  "policy": {
    "levels": {
      "0": {
        "handshake": 10,
        "connIdle": 100,
        "uplinkOnly": 2,
        "downlinkOnly": 3,
        "statsUserUplink": true,
        "statsUserDownlink": true,
        "bufferSize": 10240
      }
    },
    "system": {
      "statsInboundDownlink": true,
      "statsInboundUplink": true
    }
  },
  "routing": {
    "domainStrategy": "IPIfNonMatch",
    "domainMatcher": "hybrid",
    "rules": [
      {
        "inboundTag": [
          "api"
        ],
        "outboundTag": "api",
        "type": "field"
      },
      {
        "ip": [
          "geoip:cn"
        ],
        "outboundTag": "blockedByIp",
        "type": "field"
      },
      {
        "type": "field",
        "domain": [
          "geosite:category-ads-all",
          "geosite:cn",
          "geosite:tld-cn",
          "geosite:private",
          "geosite:category-games@cn"
        ],
        "outboundTag": "blockedByDomain"
      },
      {
        "outboundTag": "blocked",
        "protocol": [
          "bittorrent"
        ],
        "type": "field"
      }
    ]
  },
  "stats": {}
}

保存配置后重启面板,服务器内使用如下命令实时查看日志:

tail -f /usr/local/x-ui/bin/access.log | grep -v 127.0.0.1    

谢谢,我试过了,已经可以了。

再顺带问下,如果这个日志需要按天来分割,请问下如何解决啊。