Skip to content

Latest commit

ย 

History

History
401 lines (260 loc) ยท 6.03 KB

File metadata and controls

401 lines (260 loc) ยท 6.03 KB

๐Ÿš€ Netlify XHTTP Relay

Simple Netlify Edge Function relay project
Created by amirs


๐Ÿ‡ฎ๐Ÿ‡ท Persian Guide

Persian version: README_FA.md


โš ๏ธ Important Notice

Use this project only with your own domain/server or with permission.


โœจ Features

  • Netlify Edge Function relay
  • Simple setup
  • Works with Netlify website and Netlify CLI
  • Environment variable based backend target
  • Supports target domain with port

๐Ÿ“ฆ Project Structure

.
โ”œโ”€โ”€ netlify/
โ”‚   โ””โ”€โ”€ edge-functions/
โ”‚       โ””โ”€โ”€ relay.js
โ”œโ”€โ”€ public/
โ”‚   โ””โ”€โ”€ index.html
โ”œโ”€โ”€ netlify.toml
โ”œโ”€โ”€ package.json
โ”œโ”€โ”€ README.md
โ””โ”€โ”€ README_FA.md

๐Ÿด Deploy by Forking This Repository

This method works, but it is not recommended for most users.
Recommended method: download/copy the project and deploy your own version.

๐Ÿ” Required Environment Variable

You must set:

TARGET_DOMAIN=https://your-domain.com:443

Important

The domain must include port.

Correct examples:

https://example.com:443
https://sub.example.com:443
https://api.example.com:8443

Wrong examples:

https://example.com
example.com:443
http://example.com:443
localhost:443
127.0.0.1:443

๐Ÿš€ Deploy with Netlify Website

Use this project directly.

1. Import project

Go to Netlify:

https://app.netlify.com

Then:

Add new project โ†’ Import an existing project

Select your repository.


2. Build settings

Use:

Setting Value
Build command npm run build
Publish directory public

3. Add Environment Variable

Go to:

Site configuration โ†’ Environment variables โ†’ Add variable

Add:

Key: TARGET_DOMAIN
Value: https://your-domain.com:443

Example:

TARGET_DOMAIN=https://example.com:443

4. Redeploy

After adding TARGET_DOMAIN, redeploy:

Deploys โ†’ Trigger deploy โ†’ Deploy site


๐Ÿด Deploy by Forking This Repository

This method works, but it is not recommended for most users.
Recommended method: download/copy the project and deploy your own version.

Why fork is not recommended?

  • Your project stays connected to the original repository history
  • Beginners may get confused with GitHub fork/update options
  • If you want a clean personal project, copying the files is better

If you still want to use Fork

  1. Open this project on GitHub
  2. Click Fork
  3. Choose your GitHub account
  4. After fork is created, go to Netlify
  5. Click:
Add new project โ†’ Import an existing project โ†’ GitHub
  1. Select your forked repository
  2. Use these build settings:
Setting Value
Build command npm run build
Publish directory public
  1. Add environment variable:
TARGET_DOMAIN=https://your-domain.com:443
  1. Deploy the site

After changing TARGET_DOMAIN, always redeploy.

๐Ÿ’ป Deploy with Netlify CLI

1. Install Netlify CLI

npm install -g netlify-cli

2. Go to project folder

cd path/to/project

3. Login

netlify login

4. Link project

If your site already exists on Netlify:

netlify link

If you want CLI to create the site:

netlify init

5. Set TARGET_DOMAIN

The value must include port:

netlify env:set TARGET_DOMAIN "https://your-domain.com:443" --scope functions --context production

Example:

netlify env:set TARGET_DOMAIN "https://example.com:443" --scope functions --context production

6. Check env

netlify env:list

or:

netlify env:get TARGET_DOMAIN --context production

7. Deploy

netlify deploy --prod

๐Ÿงช Usage

What you open What it forwards to
https://your-site.netlify.app/ https://your-domain.com:443/
https://your-site.netlify.app/path https://your-domain.com:443/path
https://your-site.netlify.app/api/test https://your-domain.com:443/api/test

๐Ÿ”— Example Config

Replace placeholders with your own values.

vless://UUID@xxxxx=SNi:443?encryption=none&security=tls&sni=xxx&fp=chrome&alpn=h2%2Chttp%2F1.1&insecure=0&allowInsecure=0&type=xhttp&host=YOUR_NETLIFY_DOMAIN&path=YOUR_PATH&mode=auto&extra=%7B%22xPaddingBytes%22%3A%22100-1000%22%7D#net

Replace these

Placeholder Meaning
UUID Your UUID
YOUR_NETLIFY_DOMAIN Your Netlify domain, for example your-site.netlify.app
YOUR_PATH Your backend path

Use this sni - adress for your config:

kubernetes.io
helm.sh
letsencrypt.org

๐Ÿž Debug

Check deploy logs

Site โ†’ Deploys โ†’ Latest deploy โ†’ View logs

Check Edge Function logs

Site โ†’ Edge Functions โ†’ relay โ†’ Logs

Check env

netlify env:list
netlify env:get TARGET_DOMAIN --context production

Test your backend

curl -I "https://your-domain.com:443"

If this command fails, fix your backend/domain/port first.


โŒ Common Errors

Error Reason Fix
dns error Domain cannot be resolved Check domain DNS
connection refused Port is closed Open the port or use correct port
SSL/TLS error Certificate/SNI problem Use correct domain and valid SSL
Still using old domain Old deploy/env Set env again and redeploy
404 Route problem Check netlify.toml

โœ… Quick Checklist

  • TARGET_DOMAIN is set
  • TARGET_DOMAIN includes https://
  • TARGET_DOMAIN includes port
  • Backend domain resolves publicly
  • Backend port is open
  • You redeployed after changing env

๐Ÿ’ฐ Donate

https://reymit.ir/amirshaker

Solana:

E7S8EBUE5tkY5UaTgDvhaanJMeCi2DxPGYZukJGrJV8J

๐Ÿ“ข Telegram Channel

https://t.me/avaco_cloud

๐Ÿ’ฌ Contact

@ShakerFPS

๐Ÿ‘ค Author

amirs


๐Ÿ“œ License

MIT License ยฉ amirs