huedaya.com/blog
just bunch of .md files
How to Create V2Ray Subscription URL

The V2Ray Subscription works similar to RSS Feed. Its consist list of config encoded in Base64. Here the sample of the content:

plaintext
dm1lc3M6Ly9ld29nSUNKMklqb2dJaklpTEFvZ0lDSndjeUk2SUNKMGFHVXRZMjl1Wm1sbkxXNWhiV1VpTEFvZ0lDSmhaR1FpT2lBaVpYVXVaWGhoYlhCc1pTNXVaWFFpTEFvZ0lDSndiM0owSWpvZ0lqZ3dJaXdLSUNBaWFXUWlPaUFpWkdWaU56VXpZMlF0TkdFd1lpMW1abVptTFdFM1lqSXRaVE0wWW1VME1XRTROekkySWl3S0lDQWlZV2xrSWpvZ0lqQWlMQW9nSUNKelkza2lPaUFpWVhWMGJ5SXNDaUFnSW01bGRDSTZJQ0ozY3lJc0NpQWdJblI1Y0dVaU9pQWlibTl1WlNJc0NpQWdJbWh2YzNRaU9pQWlaWFV1WlhoaGJYQnNaUzV1WlhRaUxBb2dJQ0p3WVhSb0lqb2dJaTkyYldWemN5SXNDaUFnSW5Sc2N5STZJQ0p1YjI1bElpd0tJQ0FpYzI1cElqb2dJbVYxTG1WNFlXMXdiR1V1Ym1WMElpd0tJQ0FpWVd4d2JpSTZJQ0lpQ24wPQp2bWVzczovL2V3b2dJQ0oySWpvZ0lqSWlMQW9nSUNKd2N5STZJQ0owYUdVdFkyOXVabWxuTFc1aGJXVXRNaUlzQ2lBZ0ltRmtaQ0k2SUNKbGRTNWxlR0Z0Y0d4bExtNWxkQ0lzQ2lBZ0luQnZjblFpT2lBaU9EQWlMQW9nSUNKcFpDSTZJQ0prWldJM05UTmpaQzAwWVRCaUxXWm1abVl0WVRkaU1pMWxNelJpWlRReFlUZzNNallpTEFvZ0lDSmhhV1FpT2lBaU1DSXNDaUFnSW5OamVTSTZJQ0poZFhSdklpd0tJQ0FpYm1WMElqb2dJbmR6SWl3S0lDQWlkSGx3WlNJNklDSnViMjVsSWl3S0lDQWlhRzl6ZENJNklDSmxkUzVsZUdGdGNHeGxMbTVsZENJc0NpQWdJbkJoZEdnaU9pQWlMM1p0WlhOeklpd0tJQ0FpZEd4eklqb2dJbTV2Ym1VaUxBb2dJQ0p6Ym1raU9pQWlaWFV1WlhoaGJYQnNaUzV1WlhRaUxBb2dJQ0poYkhCdUlqb2dJaUlLZlE9PQ==

After Base64 Decode:

plaintext
vmess://ewogICJ2IjogIjIiLAogICJwcyI6ICJ0aGUtY29uZmlnLW5hbWUiLAogICJhZGQiOiAiZXUuZXhhbXBsZS5uZXQiLAogICJwb3J0IjogIjgwIiwKICAiaWQiOiAiZGViNzUzY2QtNGEwYi1mZmZmLWE3YjItZTM0YmU0MWE4NzI2IiwKICAiYWlkIjogIjAiLAogICJzY3kiOiAiYXV0byIsCiAgIm5ldCI6ICJ3cyIsCiAgInR5cGUiOiAibm9uZSIsCiAgImhvc3QiOiAiZXUuZXhhbXBsZS5uZXQiLAogICJwYXRoIjogIi92bWVzcyIsCiAgInRscyI6ICJub25lIiwKICAic25pIjogImV1LmV4YW1wbGUubmV0IiwKICAiYWxwbiI6ICIiCn0=
vmess://ewogICJ2IjogIjIiLAogICJwcyI6ICJ0aGUtY29uZmlnLW5hbWUtMiIsCiAgImFkZCI6ICJldS5leGFtcGxlLm5ldCIsCiAgInBvcnQiOiAiODAiLAogICJpZCI6ICJkZWI3NTNjZC00YTBiLWZmZmYtYTdiMi1lMzRiZTQxYTg3MjYiLAogICJhaWQiOiAiMCIsCiAgInNjeSI6ICJhdXRvIiwKICAibmV0IjogIndzIiwKICAidHlwZSI6ICJub25lIiwKICAiaG9zdCI6ICJldS5leGFtcGxlLm5ldCIsCiAgInBhdGgiOiAiL3ZtZXNzIiwKICAidGxzIjogIm5vbmUiLAogICJzbmkiOiAiZXUuZXhhbXBsZS5uZXQiLAogICJhbHBuIjogIiIKfQ==

Each line actually JSON config encoded in Base64. So here is simple Laravel PHP controller that return V2Ray Subscription format.

php
<?php

namespace App\Http\Controllers\Api;

use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Routing\Controller;

class V2RayController extends Controller
{
    public function get(): Response
    {
        // List
        $list = [
            'vmess://ew...',
            'vmess://ew...',
            'vmess://ew...',
        ];

        // Append
        $response = '';
        foreach ($list as $value) {
            $response .= $value.PHP_EOL;
        }

        // Encode
        $response = base64_encode($response);

        return response($response, 200)->header('Content-Type', 'text/plain');
    }
}

That's it!

Bonus: Client list can be found here

Last update: 2024-02-28 05:35:18 (1 month ago)