Cloudflare VLESS and Trojan Proxy Deployment

repository·main·Indexed 12 days ago

https://github.com/yonggekkk/cloudflare-vless-trojan

A collection of scripts for deploying VLESS and Trojan proxy nodes using Cloudflare Workers and Pages. Features include local Socks5/HTTP proxying via cfsh.sh, support for ECH and TLS, NAT64 support, and tools for optimizing Cloudflare CDN IPs and domains. Version 25.5.4 supports sing-box and clash subscriptions without third-party converters.

Tokens
2.5K
Snippets
5
Records
17
Agent score
47%

What's inside cloudflare-vless-trojan

  1. Deploy Cloudflare-workers/pages Proxy Script

    main

    This method (current version: 25.5.4) is designed for local deployment and local configuration editing. It does not use third-party subscription converters, ensuring your node information remains private.

    Key Features:

    • Workers Mode: Supports vless+ws+tls, trojan+ws+tls, vless+ws, and trojan+ws.
    • Pages Mode: Supports vless+ws+tls and trojan+ws+tls.
    • Subscription Support: Supports single node links, aggregated nodes, sing-box subscriptions, and clash subscriptions.
    • NAT64 Support: VLESS NAT64 versions automatically fill proxyip.
  2. Customize ProxyIP for Single Nodes or Global Settings

    main

    You can override the proxyip using two methods:

    1. Global Node Variable

    Set the proxyip variable as described in the VLESS/Trojan configuration. This affects all nodes that do not have a specific path-based proxyip set.

    2. Single Node Path Method

    You can specify a proxyip for a specific node by appending a path parameter. This takes precedence over the global proxyip.

    PortIPv4 FormatIPv6 FormatDomain Format
    443/pyip=IPV4_ADDRESS/pyip=[IPV6_ADDRESS]/pyip=DOMAIN
    Non-443/pyip=IPV4:PORT/pyip=[IPV6]:PORT/pyip=DOMAIN:PORT

    Note: Changing the path-based proxyip only affects that specific node.

  3. Run Cloudflare CDN optimized domain script on iOS (iSH)

    main

    To run the script on iOS, use iSH version 1.2.2 (newer versions have bugs that cause the script to hang). You may need to use TrollStore or other methods to install this specific version.

    1. Install iSH 1.2.2.
    2. Install dependencies:
      apk add curl bash
    3. Run the script (see next record for the command).
    apk add curl bash
  4. Retrieve Configuration Info and Share Links

    main

    To view your configuration or share links via a web browser, use the following URL patterns:

    • CF Vless: https://<workers_or_pages_or_custom_domain>/<your_uuid>
    • CF Trojan: https://<workers_or_pages_or_custom_domain>/<your_password>

    Note: If your domain is blocked, you must use a proxy to access these URLs.

  5. Bulk import variables into Cloudflare Workers

    main

    Once the script has run and generated the configuration:

    1. Go to your Cloudflare Worker settings.
    2. Navigate to Settings -> Variables and Secrets.
    3. Click Add Variable (or similar action to add bulk values).
    4. Click into the black input box below the variable name and press CTRL+V to paste the clipboard content generated by the script.
    5. If some variables are missing, click Save and Deploy to ensure all settings are applied.
  6. Prepare test results for variable generation

    main

    Before running the script, you must organize your optimized IP and domain results in the following directory structure so the script can locate the latest data:

    1. Create a History folder: Inside the domain and ip directories, ensure a History folder exists.
    2. Organize by date: Inside History, create a folder named using the YYYY_MM-DD format (e.g., 2026_02-11).
    3. Place domain results: Put your optimized domain results in domain/History/YYYY_MM-DD/CDNym.txt.
    4. Place IP results:
      • For IPv4: Place results in ip/History/YYYY_MM-DD/result.csv.
      • For IPv6: Place results in ip/History/YYYY_MM-DD/result_v6.csv. (Tip: Use the _v6 suffix for IPv6 files if applicable).
  7. Use the Variable Import Tool (自动生成变量导入cf.py)

    main

    This Python script automates the process of importing optimized IP and domain variables into Cloudflare Workers. Instead of manually copying results from .txt or .csv files, the script aggregates the latest test results, generates a worker.env file, and copies the configuration to your clipboard for bulk import into the Cloudflare dashboard.

    python 自动生成变量导入cf.py
  8. Run Cloudflare CDN optimized domain script on Android (Termux)

    main

    To run the Cloudflare CDN optimized public domain script on Android, you must use the official Termux app (the Google Play Store version is not compatible).

    1. Install Termux.
    2. Update dependencies:
      pkg upgrade
    3. Run the script (see next record for the command).
    pkg upgrade
  9. Recommended clients for Fragment (分片) functionality

    main

    The Fragment (分片) feature helps bypass TLS blocking on domains that have been blocked by firewalls, allowing Workers domains to support TLS nodes.

    Important Notes:

    • If you are using a custom domain or a Pages domain that is NOT subject to TLS blocking, you do not need to enable Fragment.
    • For Workers domains, the six 443-port TLS nodes are unusable if the client does not support and enable the Fragment feature.
    • Known Issue: Currently, the TLS fragment functionality for Workers may be ineffective.
    • Trojan+WS Limitation: Clients like Shadowrocket, v2box, v2rayN, and v2rayNG have mandatory TLS requirements for trojan+ws which may cause connection failures. Clash subscriptions do not support trojan+ws nodes.
  10. Install Cloudflare-Socks5/Http Local Proxy Script

    main

    This method is intended for use on local platforms like soft routers. It supports Workers domains, Pages domains, and custom domains. You can choose between ECH-TLS, standard TLS, or no TLS modes to handle different blocking scenarios.

    Use the cfsh.sh script or the ygkkk/cfsh Docker image.

    curl -sSL https://raw.githubusercontent.com/yonggekkk/Cloudflare_vless_trojan/main/s5http_wkpgs/cfsh.sh -o cfsh.sh && chmod +x cfsh.sh && bash cfsh.sh
  11. Configure VLESS and Trojan Variables for Workers/Pages

    main

    When deploying via Workers or Pages, use these variables to customize your nodes:

    VLESS Node Variables

    VariableNameRequirementDefault
    1uuidValid UUID format86c50e3a-5b87-49dd-bd20-03c7f2735e40
    2proxyipIPv4, [IPv6], or DomainScript default
    3ip1 to ip13CF Official/Reverse/Optimized IP/Domainygkkk.com (example)
    4pt1 to pt13CF Standard PortsCF standard ports

    Trojan Node Variables

    VariableNameRequirementDefault
    1pswdAlphanumerictrojan
    2proxyipIPv4, [IPv6], or DomainScript default
    3ip1 to ip13CF Official/Reverse/Optimized IP/Domainygkkk.com (example)
    4pt1 to pt13CF Standard PortsCF standard ports

    Important Note on Subscription Variables (3 & 4):

    • ip1-ip7 and pt1-pt7 are for 80 series (No TLS) nodes.
    • ip8-ip13 and pt8-pt13 are for 443 series (TLS) nodes.