Skip to content
TheChatArchiveThe Chat Archive
gpt-4o-2024-08-06· OpenAIAi2 WildChat-4.8M (AI2)

Marzban how to limit one connection for subscription vless + reality with access by key

  1. User

    Marzban how to limit one connection for subscription vless + reality with access by key

  2. Assistant

    Implementing a system to limit one connection per subscription using VLESS with Reality requires setting up a secure and controlled environment. This involves configuring your server to enforce connection restrictions and handle authentication with access keys. Here's a general outline of how you might set this up:

    Prerequisites

    • A VPS or server to run a VLESS server (such as Xray or V2Ray).
    • A domain name with DNS pointing to your server.
    • Basic knowledge of Linux and server management.

    Setup Steps

    1. Install V2Ray or Xray:

      • Connect to your VPS via SSH.

      • Install V2Ray or Xray. You can find installation scripts online, such as:

        bash <(curl -L -s https://install.direct/go.sh)
        
      • Or follow the specific setup steps for Xray.

    2. Configure VLESS:

      • Edit the V2Ray/Xray configuration file (typically located at /etc/v2ray/config.json or /usr/local/etc/xray/config.json).
      • Add a VLESS inbound configuration, ensuring you set it up to use Reality for encryption.
      • Configure Reality by including the reality attribute with the necessary parameters (e.g., dest, serverNames, privateKey, etc.).
    3. Implement Access by Key:

      • Use UUIDs as access keys. Each subscriber should have a unique UUID which is tied to that user. You can generate UUIDs using a tool like uuidgen.
    4. Limit Connections:

      • Within the VLESS configuration, limit connections to one by setting the concurrency field. However, V2Ray itself doesn’t have a built-in limit for the number of connections per UUID, so you might need a script or an additional layer to enforce single connections if that's not inherently supported.

      • Example JSON snippet:

        {
          "inbounds": [
            {
              "port": 443,
              "protocol": "vless",
              "settings": {
                "clients": [
                  {
                    "id": "YOUR-UUID",
                    "level": 0,
                    "email": "user@example.com"
                  }
                ],
                "decryption": "none"
              },
              "streamSettings": {
                "network": "tcp",
                "realitySettings": {
                  "dest": "example.com:443",
                  "serverNames": ["example.com"],
                  "privateKey": "YOUR-PRIVATE-KEY"
                }
              }
            }
          ]
        }
        
    5. Set Up Monitoring or Scripting (Optional):

      • To enforce a one-connection policy, you may need a script to track active connections and enforce disconnections when a user hits their limit.
      • Alternatively, use firewall rules or server monitoring tools to restrict access based on conditions you define.
    6. Testing and Deployment:

      • Restart the V2Ray/Xray service to apply your configurations:

        systemctl restart v2ray
        
      • Test the connection using a client configured with the VLESS and Reality settings to ensure everything is working as intended.

    7. Security Measures:

      • Ensure that your server's firewall is configured to allow only necessary traffic.
      • Regularly update your server software and monitor logs for suspicious activities.

    Remember, actual implementation details could vary based on the specific software versions and your server setup. Always back up existing configurations before making changes and consider consulting official documentation or communities if you encounter issues.