Skip to content

mamadiam/vmess-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 

Repository files navigation

VMess Proxy with an IR Server as a Router

For this you need two servers, one in Iran and the other outside of Iran.
you can google it or using websites like Sindad or ParsPack or any other services you like.
Note: You don't need anything fancy, even the most basic and simple plans of the VPS's will do the magic.



Your server inside Iran will act as a router. It's only job is to route traffic from within the country to the main server (non-IR) which hosts the actual Vmess proxy.
All commands are base on debian-based linux distros. e.g. Ubuntu.

Note: There is no authentication mechanism applied for the sake of simplicity.
Share it with your loved ones

#MahsaAmini
#womanlifefreedom

Let's get started.

You can either clone this repo on your servers and just set your configurations or go by the following steps.

on Your non-IR Server

1. update & upgrade the packages

sudo apt update && apt upgrade -y

2. Create & edit docker compose

nano docker-compose.yaml

3. Add the following to the docker-compose.yaml file and save:

version: "3"
services:
  v2ray443:
    image: v2fly/v2fly-core:v4.45.2
    restart: always
    network_mode: host
    environment:
      - V2RAY_VMESS_AEAD_FORCED=false
    volumes:
      - ./config.json:/etc/v2ray/config.json:ro

4. Create & edit docker compose

nano config.json

5. Add the following to the config.json file:

Navigate to UUID Generator and grab a UUID V1, and replace it with xxx-xxx-xxx
Write your UUID in notepad, you gonna need it later.

{
  "log": {
    "loglevel": "warning"
  },
  "inbounds": [
    {
      "port": 80,
      "protocol": "vmess",
      "allocate": {
        "strategy": "always"
      },
      "settings": {
        "clients": [
          {
            "id": "xxx-xxx-xxx",
            "level": 1,
            "alterId": 0,
            "email": "client@example.com"
          }
        ],
        "disableInsecureEncryption": true
      },
      "streamSettings": {
        "network": "ws",
        "wsSettings": {
          "connectionReuse": true,
          "path": "/graphql"
        },
        "security": "none",
        "tcpSettings": {
          "header": {
            "type": "http",
            "response": {
              "version": "1.1",
              "status": "200",
              "reason": "OK",
              "headers": {
                "Content-Type": [
                  "application/octet-stream",
                  "application/x-msdownload",
                  "text/html",
                  "application/x-shockwave-flash"
                ],
                "Transfer-Encoding": ["chunked"],
                "Connection": ["keep-alive"],
                "Pragma": "no-cache"
              }
            }
          }
        }
      }
    }
  ],
  "outbounds": [
    {
      "protocol": "freedom",
      "settings": {}
    }
  ]
}

6. Save & close your config.json.

7. Or instead, Replace the YOUR_NEW_UUID in the following command with your newly generated UUID

sed -i 's/xxx-xxx-xxx/YOUR_NEW_UUID/g' ./config.json

Note: the docker-compose.yaml and config.json files need to be under the same directory.

8. Install docker and docker-compose:

sudo apt install docker docker-compose

9. Start the Vmess Server

docker-compose up -d

That's it for your non-IR Server, now let's setup you IR Server.

on Your IR Server

1. update & upgrade the packages

sudo apt update && apt upgrade -y

2. install iptables persistent

sudo apt install iptables-persistent

3. edit this file:

sudo nano /etc/iptables/rules.v4

4. Add the following to the rules.v4 file and save:

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A FORWARD -d xx.xx.xx.xx -p tcp -m tcp --dport 80 -j ACCEPT
-A FORWARD -d xx.xx.xx.xx -p udp -m udp --dport 80 -j ACCEPT
COMMIT
*nat
:PREROUTING ACCEPT [0:0]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
:POSTROUTING ACCEPT [0:0]
-A PREROUTING -p tcp -m tcp --dport 80 -j DNAT --to-destination xx.xx.xx.xx
-A PREROUTING -p udp -m udp --dport 80 -j DNAT --to-destination xx.xx.xx.xx
-A POSTROUTING -d xx.xx.xx.xx -p tcp -m tcp --dport 80 -j MASQUERADE
-A POSTROUTING -d xx.xx.xx.xx -p udp -m udp --dport 80 -j MASQUERADE
COMMIT

5. Replace NON_IR_IP with your non-IR server IPv4 and run the command:

sudo sed -i 's/xx.xx.xx.xx/NON_IR_IP/g' /etc/iptables/rules.v4

This will replace all occurences of xx.xx.xx.xx with the actual IP address of your non-IR server.

6. Open this file:

sudo nano /etc/sysctl.conf

Add the following line to the beginning of the file (or just find it and uncomment it) and save:

net.ipv4.ip_forward=1

7. Run next two commands to make the changes take effect right away:

sudo sysctl -p
sudo systemctl restart iptables.service

Now head over to the Guide directory for instructions on how to connect to your server using a Vmess client.

Just in case you want to support me, I'd realy appriciate it.

TRC20 TT2AMeebAUGFcG9jLPA49xN1eMCyDekz6c

ERC20 0x9A6471A8d01A66e81433d97aF3e1288f7C2E6a7b