Skip to content

Instantly share code, notes, and snippets.

@zpoint
Last active November 6, 2024 20:25
Show Gist options
  • Save zpoint/df2483c6beb97816e34ddbde3f62f5d8 to your computer and use it in GitHub Desktop.
Save zpoint/df2483c6beb97816e34ddbde3f62f5d8 to your computer and use it in GitHub Desktop.
v2ray + openvpn to unblock gfw and netflix

If you're using wireguard please refer to v2ray+wireguard to bypass GFW and netflix/spotify/hulu

Two things need to be paid

  • vps(such as bandwagonhost)
    • If you are using China Telecom, a CN2 network is required, or you may get stuck when streaming video
    • For bandwagonhost, you need to login, click Client Area -> Services -> Order New Services to get CN2 server
  • vpn vendor to unblock netflix(a openvpn connection that can unblock netflix)

vpn

The basic idea is setup a socks5 proxy to forawrd all network traffic from the socks5 to a specific openvpn, in v2ray, forward all the netflix traffic to the socks5 proxy

detail

Why not connect to the openvpn directly ?

The openvpn connection is highly unstable or slow due to GFW

Why not connect to VPS directly ?

You can easily get a fast VPS(CN2) from various provider, but most of them can't combined the fast and stable connection from China && unblock from the netflix

So, I decide to do it myself

Steps

  1. install v2ray

    bash <(curl -s -L https://git.io/v2ray.sh)
    
  2. config openvpn connection inside a docker container

In most case the following command can't set up properly, please read the Notice part to change the configuration if there's something wrong

    git clone https://github.com/zpoint/openvpn_socks5_docker.git
    cd openvpn_socks5_docker
    ./build.sh
    ./start.sh
    launch *.ovpn
  1. exit the docker container, change your v2ray configure file to forward the netflix traffic to the openvpn connection inside the container, this is part of my configure file located in /etc/v2ray/config.json

    "inbounds": [
     {
      "port": 8888,
      "protocol": "vmess",
      "settings": {
       "clients": [
        {
         // private config
        }
       ]
      },
      "streamSettings": {
       "network": "ws"
      },
      "sniffing": {
       "enabled": true,
       "destOverride": [
        "http",
        "tls"
       ]
      }
     }
    ]
    
    
    "outbounds": [
     {
      "protocol": "socks",
      "settings": {
       "servers": [{
        "port": 9050,
        "address": "localhost"
       }]
      },
      "streamSettings": {
       "tcpSettings": {
        "header": {
         "type": "none"
        }
       },
       "network": "tcp",
       "security": "none"
      },
      "tag": "streaming"
     }
    ]
    
    "routing": {
     "domainStrategy": "IPOnDemand",
     "rules": [
         {
       "type": "field",
       "domain": [
        "domain:btstatic.com",
        "domain:netflix.com",
        "domain:netflix.net",
        "domain:nflxext.com",
        "domain:nflximg.com",
        "domain:nflximg.net",
        "domain:nflxsearch.net",
        "domain:nflxso.net",
        "domain:nflxvideo.net",
        "domain:ipaddress.com"
       ],
       "outboundTag": "streaming"
      }
     ]
    }
    

image title

@forsolihot
Copy link

@zpoint @ALL
Hi,
Can I use Trojan instead of v2ray?
If it's possible, could you provide me with a guide?

@ackl
Copy link

ackl commented Jun 20, 2023

I believe v2ray already supports the use of trojan (https://github.com/v2fly/v2ray-core/tree/master/proxy/trojan), so you can still follow the original guide on this gist, but use trojan instead of vmess protocol on the inbound config block for your server. And on your client v2ray, use trojan on the outbound config. https://www.v2fly.org/en_US/v5/config/proxy/trojan.html

@forsolihot
Copy link

thank you so much^^

@forsolihot
Copy link

forsolihot commented Jun 27, 2023

@zpoint @ackl @mehdi198080

Hi,
I tried to test, OK. no problem.
curl --socks5 [::1]:9050

But, I seem to having an issue with the v2ray config
help me !

Here is my v2ray conf


`

{
"log" : {
"access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log",
"loglevel": "warning"
},

"inbound": {
"port": 20478,
"protocol": "vmess",
"settings": {
"clients": [
{
"id": "2ccbe244-96e4-4ae1-b761-3d86666f6a93",
"encryption": "aes-128-gcm",
"level": 1,
"alterId": 64
}
]
},
"streamSettings": {
"network": "ws"
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
},

"outbound": [
{
"protocol": "socks",
"settings": {
"servers": [{
"port": 9050,
"address": "localhost"
}]
},
"streamSettings": {
"tcpSettings": {
"header": {
"type": "none"
}
},
"network": "tcp",
"security": "none"
},
"tag": "streaming"
}
],

"routing": {
"domainStrategy": "IPOnDemand",
"rules": [
{
"type": "field",
"domain": [
"domain:btstatic.com",
"domain:netflix.com",
"domain:netflix.net",
"domain:nflxext.com",
"domain:nflximg.com",
"domain:nflximg.net",
"domain:nflxsearch.net",
"domain:nflxso.net",
"domain:nflxvideo.net",
"domain:ipaddress.com"
],
"outboundTag": "streaming"
}
]
}
}

`

@oops10101
Copy link

redirect-gateway def1

hey there I'm having the same problem but I don't know how to check for the redirect-gateway def1 option in my OpenVPN config can you help me with this?

@ackl
Copy link

ackl commented Aug 16, 2024

@oops10101 You just need to open the ,ovpn config file and try CTRL-F for the string 'redirect-gateway def1'

@oops10101
Copy link

oops10101 commented Aug 16, 2024 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment