Marzban how to limit one connection for subscription
- User
Marzban how to limit one connection for subscription
- Assistant
Marzban how to limit one connection for subscription
To limit one connection per subscription in a Marzban (a tool used for managing VPN services like V2Ray or Xray), you generally need to adjust your server configurations and potentially your subscription management logic. Here are some general steps to guide you in achieving this:
Ensure you understand how Marzban operates in conjunction with V2Ray or Xray. It’s crucial because changes will usually be made at the V2Ray/Xray configuration level.
You will need to configure your V2Ray or Xray instance to limit connections. Here’s a general approach:
Inbound Configuration:
Modify your inbound configuration to set a connection limit. This can be done through the clients section where you define user-specific constraints.
Connection Limit:
Implement connection limits through the configuration for each user or globally. For instance, in your inbound settings, you can specify constraints:
{
"inbounds": [
{
"port": 443,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "uuid",
"alterId": 0,
"statsUserUplink": true,
"statsUserDownlink": true,
"level": 0,
"email": "user@example.com"
}
]
},
"streamSettings": {
// your stream settings
},
"allocate": {
"strategy": "always",
"concurrency": 1 /* Limit to 1 connection at a time */
}
}
],
"policy": {
"levels": {
"0": {
"handshake": 2,
"connIdle": 300,
"uplinkOnly": 2,
"downlinkOnly": 5,
"bufferSize": 1024,
"statsUserUplink": true,
"statsUserDownlink": true,
"connLimit": 1 /* Global connection limit */
}
}
}
}
If you are managing subscriptions manually or programmatically, ensure that each subscription is assigned a unique user ID and configured in your V2Ray/Xray instance’s client list as above.
Implement additional monitoring to ensure that the connection limit is enforced:
Logs and Alerts: Regularly check the server logs to monitor connection attempts and identify any issues with limit enforcement.
Additional Tools: Use tools like Fail2ban to monitor and block IPs with suspicious activities.
UUID Management: Ensure every subscription is tied to a unique UUID so you can precisely control user connections.
Customer Support: Prepare a support plan for customers who may face connection issues due to the imposed limits.
Implementing connection limits requires careful planning and testing to avoid disrupting service for legitimate users. If you are using Marzban’s web interface or plugins, check if there are specific options available for managing connections per subscription directly from the UI.
Not yet included in a published release.