Install V2Ray on Linux

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)
bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh)

/etc/systemd/system/v2ray.service

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
[Unit]
Description=V2Ray Service
Documentation=https://www.v2fly.org/
After=network.target nss-lookup.target
[Service]
User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json
Restart=on-failure
RestartPreventExitStatus=23
[Install]
WantedBy=user. Target
[Unit] Description=V2Ray Service Documentation=https://www.v2fly.org/ After=network.target nss-lookup.target [Service] User=nobody CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE NoNewPrivileges=true ExecStart=/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json Restart=on-failure RestartPreventExitStatus=23 [Install] WantedBy=user. Target
[Unit]
Description=V2Ray Service
Documentation=https://www.v2fly.org/
After=network.target nss-lookup.target

[Service]
User=nobody
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE
NoNewPrivileges=true
ExecStart=/usr/local/bin/v2ray run -config /usr/local/etc/v2ray/config.json
Restart=on-failure
RestartPreventExitStatus=23

[Install]
WantedBy=user. Target
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
installed: /usr/local/bin/v2ray
installed: /usr/local/share/v2ray/geoip.dat
installed: /usr/local/share/v2ray/geosite.dat
installed: /usr/local/etc/v2ray/config.json
installed: /var/log/v2ray/
installed: /var/log/v2ray/access.log
installed: /var/log/v2ray/error.log
installed: /etc/systemd/system/v2ray.service
installed: /etc/systemd/system/v2ray@.service
installed: /usr/local/bin/v2ray installed: /usr/local/share/v2ray/geoip.dat installed: /usr/local/share/v2ray/geosite.dat installed: /usr/local/etc/v2ray/config.json installed: /var/log/v2ray/ installed: /var/log/v2ray/access.log installed: /var/log/v2ray/error.log installed: /etc/systemd/system/v2ray.service installed: /etc/systemd/system/v2ray@.service
installed: /usr/local/bin/v2ray
installed: /usr/local/share/v2ray/geoip.dat
installed: /usr/local/share/v2ray/geosite.dat
installed: /usr/local/etc/v2ray/config.json
installed: /var/log/v2ray/
installed: /var/log/v2ray/access.log
installed: /var/log/v2ray/error.log
installed: /etc/systemd/system/v2ray.service
installed: /etc/systemd/system/v2ray@.service
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
systemctl enable v2ray; systemctl start v2ray
systemctl enable v2ray; systemctl start v2ray
systemctl enable v2ray; systemctl start v2ray

Remove V2Ray

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove
# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove
# bash <(curl -L https://raw.githubusercontent.com/v2fly/fhs-install-v2ray/master/install-release.sh) --remove

References
https://github.com/v2fly/fhs-install-v2ray

Pass Google Traffic through WARP with V2ray in Ubuntu

Install warp-cli

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
curl https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg
curl https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg
curl https://pkg.cloudflareclient.com/pubkey.gpg | sudo gpg --yes --dearmor --output /usr/share/keyrings/cloudflare-warp-archive-keyring.gpg
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/cloudflare-warp-archive-keyring.gpg] https://pkg.cloudflareclient.com/ $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/cloudflare-client.list
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo apt update
sudo apt update
sudo apt update
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo apt install cloudflare-warp
sudo apt install cloudflare-warp
sudo apt install cloudflare-warp

Run warp-cli in proxy mode

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
warp-cli --accept-tos register
warp-cli --accept-tos set-mode proxy
warp-cli --accept-tos set-proxy-port 40040
warp-cli --accept-tos connect
warp-cli --accept-tos enable-always-on
warp-cli --accept-tos register warp-cli --accept-tos set-mode proxy warp-cli --accept-tos set-proxy-port 40040 warp-cli --accept-tos connect warp-cli --accept-tos enable-always-on
warp-cli --accept-tos register
warp-cli --accept-tos set-mode proxy
warp-cli --accept-tos set-proxy-port 40040
warp-cli --accept-tos connect
warp-cli --accept-tos enable-always-on

Configure xray

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
nano /usr/local/etc/xray/config.json
nano /usr/local/etc/xray/config.json
nano /usr/local/etc/xray/config.json
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
"outbounds": [
{
"protocol": "socks",
"settings": {
"servers":[
{
"address":"127.0.0.1",
"port":40040
}
]
},
"tag": "warp"
}
],
"outbounds": [ { "protocol": "socks", "settings": { "servers":[ { "address":"127.0.0.1", "port":40040 } ] }, "tag": "warp" } ],
"outbounds": [
    {
        "protocol": "socks", 
        "settings": { 
            "servers":[
                {
                    "address":"127.0.0.1",
                    "port":40040
                }
            ]
        }, 
        "tag": "warp"
    }
],
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
"routing": {
"domainStrategy": "AsIs",
"rules": [
{
"type":"field",
"domain":[
"domain:google.com"
],
"outboundTag": "warp"
}
]
},
"routing": { "domainStrategy": "AsIs", "rules": [ { "type":"field", "domain":[ "domain:google.com" ], "outboundTag": "warp" } ] },
"routing": {
    "domainStrategy": "AsIs",
    "rules": [
        {
            "type":"field",
            "domain":[
                "domain:google.com"
            ],
            "outboundTag": "warp"
        }
    ]
},

References
https://developers.cloudflare.com/warp-client/get-started/linux
https://pkg.cloudflareclient.com/install

Install Xray + VLESS + WS + TLS + Apache + CDN on Ubuntu

Install required Ubuntu packages

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
apt install -y chrony
timedatectl set-ntp true
systemctl enable chrony && systemctl restart chrony
timedatectl set-timezone Asia/Tehran
chronyc sourcestats -v
chronyc tracking -v
date
apt install -y chrony timedatectl set-ntp true systemctl enable chrony && systemctl restart chrony timedatectl set-timezone Asia/Tehran chronyc sourcestats -v chronyc tracking -v date
apt install -y chrony
timedatectl set-ntp true
systemctl enable chrony && systemctl restart chrony
timedatectl set-timezone Asia/Tehran
chronyc sourcestats -v
chronyc tracking -v
date

Install Certbot

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot certonly --standalone
sudo snap install core; sudo snap refresh core sudo snap install --classic certbot sudo ln -s /snap/bin/certbot /usr/bin/certbot sudo certbot certonly --standalone
sudo snap install core; sudo snap refresh core
sudo snap install --classic certbot
sudo ln -s /snap/bin/certbot /usr/bin/certbot
sudo certbot certonly --standalone

result

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem
# Key is saved at: /etc/letsencrypt/live/example.com/privkey.pem
# Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem # Key is saved at: /etc/letsencrypt/live/example.com/privkey.pem
# Certificate is saved at: /etc/letsencrypt/live/example.com/fullchain.pem
# Key is saved at:         /etc/letsencrypt/live/example.com/privkey.pem

Xray

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install -u root
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install -u root
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install -u root
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# xray remove
# bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ remove --purge
# xray remove # bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ remove --purge
# xray remove
# bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ remove --purge
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# /etc/systemd/system/xray.service
# /usr/local/bin/xray run -config /usr/local/etc/xray/config.json
# /etc/systemd/system/xray.service # /usr/local/bin/xray run -config /usr/local/etc/xray/config.json
# /etc/systemd/system/xray.service
# /usr/local/bin/xray run -config /usr/local/etc/xray/config.json
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
nano /usr/local/etc/xray/config.json
nano /usr/local/etc/xray/config.json
nano /usr/local/etc/xray/config.json
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
{
"log": {
"loglevel": "warning"
},
"inbounds": [
{
"port": 10002,
"listen": "127.0.0.1",
"protocol": "vless",
"settings": {
"clients": [
{
"id": "559f6df4-0a3c-4f5f-bb95-d17888b16361",
"level": 0,
"email": "love@example.com"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "ws",
"security": "none",
"wsSettings": {
"path": "/xray"
}
}
}
],
"outbounds": [
{
"protocol": "freedom",
"settings": { },
"tag": "direct"
},
{
"protocol": "blackhole",
"settings": { },
"tag": "blocked"
}
],
"dns": {
"servers": [
"https+local://1.1.1.1/dns-query",
"1.1.1.1",
"1.0.0.1",
"8.8.8.8",
"8.8.4.4",
"localhost"
]
}
}
{ "log": { "loglevel": "warning" }, "inbounds": [ { "port": 10002, "listen": "127.0.0.1", "protocol": "vless", "settings": { "clients": [ { "id": "559f6df4-0a3c-4f5f-bb95-d17888b16361", "level": 0, "email": "love@example.com" } ], "decryption": "none" }, "streamSettings": { "network": "ws", "security": "none", "wsSettings": { "path": "/xray" } } } ], "outbounds": [ { "protocol": "freedom", "settings": { }, "tag": "direct" }, { "protocol": "blackhole", "settings": { }, "tag": "blocked" } ], "dns": { "servers": [ "https+local://1.1.1.1/dns-query", "1.1.1.1", "1.0.0.1", "8.8.8.8", "8.8.4.4", "localhost" ] } }
{
    "log": {
        "loglevel": "warning"
    },
    "inbounds": [
        {
            "port": 10002,
            "listen": "127.0.0.1",
            "protocol": "vless",
            "settings": {
                "clients": [
                    {
                        "id": "559f6df4-0a3c-4f5f-bb95-d17888b16361",
                        "level": 0,
                        "email": "love@example.com"
                    }
                ],
                "decryption": "none"
            },
            "streamSettings": {
                "network": "ws",
                "security": "none",
                "wsSettings": {
                    "path": "/xray"
                }
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "freedom", 
            "settings": { }, 
            "tag": "direct"
        }, 
        {
            "protocol": "blackhole", 
            "settings": { }, 
            "tag": "blocked"
        }
    ],
    "dns": {
    "servers": [
      "https+local://1.1.1.1/dns-query",
      "1.1.1.1",
      "1.0.0.1",
      "8.8.8.8",
      "8.8.4.4",
      "localhost"
    ]
  }
}

Xray Dat Path

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
/usr/local/share/xray
/usr/local/share/xray
/usr/local/share/xray

Apache

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
nano /etc/apache2/apache2.conf
nano /etc/apache2/apache2.conf
nano /etc/apache2/apache2.conf
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
<VirtualHost *:80>
Servername example.com
RewriteEngine on
RewriteCond %{SERVER_NAME} =example.com
RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URL} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
# change your domain
ServerName example.com
# you may have a different root
DocumentRoot /var/www/
# the SSL configuration enable https for your site and it’s also required by shadowsocks + v2ray
SSLEngine on
SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/example.com/privkey.pem
SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 +TLSv1.2 +TLSv1.3
SSLCipherSuite HIGH:!aNULL
<Location "/xray">
ProxyPass ws://127.0.0.1:10002/xray
ProxyAddHeaders Off
ProxyPreserveHost On
RequestHeader append X-Forwarded-For %{REMOTE_ADDR}s
</Location>
</VirtualHost>
<VirtualHost *:80> Servername example.com RewriteEngine on RewriteCond %{SERVER_NAME} =example.com RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URL} [END,NE,R=permanent] </VirtualHost> <VirtualHost *:443> # change your domain ServerName example.com # you may have a different root DocumentRoot /var/www/ # the SSL configuration enable https for your site and it’s also required by shadowsocks + v2ray SSLEngine on SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem SSLCertificateKeyFile /etc/letsencrypt/example.com/privkey.pem SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 +TLSv1.2 +TLSv1.3 SSLCipherSuite HIGH:!aNULL <Location "/xray"> ProxyPass ws://127.0.0.1:10002/xray ProxyAddHeaders Off ProxyPreserveHost On RequestHeader append X-Forwarded-For %{REMOTE_ADDR}s </Location> </VirtualHost>
<VirtualHost *:80>
    Servername example.com
    RewriteEngine on
    RewriteCond %{SERVER_NAME} =example.com
    RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URL} [END,NE,R=permanent]
</VirtualHost>
<VirtualHost *:443>
    # change your domain
    ServerName example.com
    # you may have a different root
    DocumentRoot /var/www/
    # the SSL configuration enable https for your site and it’s also required by shadowsocks + v2ray
    SSLEngine on
    SSLCertificateFile /etc/letsencrypt/live/example.com/fullchain.pem
    SSLCertificateKeyFile /etc/letsencrypt/example.com/privkey.pem
    SSLProtocol All -SSLv2 -SSLv3 -TLSv1 -TLSv1.1 +TLSv1.2 +TLSv1.3
    SSLCipherSuite HIGH:!aNULL
    <Location "/xray">
    ProxyPass ws://127.0.0.1:10002/xray
    ProxyAddHeaders Off
    ProxyPreserveHost On
    RequestHeader append X-Forwarded-For %{REMOTE_ADDR}s
    </Location>
</VirtualHost>

References
https://github.com/XTLS/Xray-core
https://github.com/XTLS/Xray-examples
https://github.com/v2fly/v2ray-examples
https://github.com/XTLS/Xray-install

Install Shadowsocks with v2ray-plugin

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y && sudo apt-get clean && sudo apt-get install build-essential haveged -y
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y && sudo apt-get clean && sudo apt-get install build-essential haveged -y
sudo apt-get update && sudo apt-get upgrade -y && sudo apt-get dist-upgrade -y && sudo apt-get autoremove -y && sudo apt-get clean && sudo apt-get install build-essential haveged -y
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
## Ubuntu 18.04/16.04 or Debian 9
wget -O ubuntu-ss-install.sh https://github.com/M3chD09/shadowsocks-with-v2ray-plugin-install/raw/master/ubuntu-ss-install.sh
chmod +x ubuntu-ss-install.sh
./ubuntu-ss-install.sh
## Ubuntu 18.04/16.04 or Debian 9 wget -O ubuntu-ss-install.sh https://github.com/M3chD09/shadowsocks-with-v2ray-plugin-install/raw/master/ubuntu-ss-install.sh chmod +x ubuntu-ss-install.sh ./ubuntu-ss-install.sh
## Ubuntu 18.04/16.04 or Debian 9
wget -O ubuntu-ss-install.sh https://github.com/M3chD09/shadowsocks-with-v2ray-plugin-install/raw/master/ubuntu-ss-install.sh
chmod +x ubuntu-ss-install.sh
./ubuntu-ss-install.sh
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
# Manage shadowsocks with systemctl
systemctl status shadowsocks
systemctl start shadowsocks
systemctl stop shadowsocks
# Manage shadowsocks with systemctl systemctl status shadowsocks systemctl start shadowsocks systemctl stop shadowsocks
# Manage shadowsocks with systemctl
systemctl status shadowsocks
systemctl start shadowsocks
systemctl stop shadowsocks
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
nano /etc/shadowsocks-libev/config.json
nano /etc/shadowsocks-libev/config.json
nano /etc/shadowsocks-libev/config.json
Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
{
"server":"0.0.0.0",
"server_port":80,
"password":"PASSWORD",
"timeout":300,
"user":"nobody",
"method":"aes-256-gcm",
"nameserver": "8.8.8.8",
"fast_open":true,
"reuse_port":true,
"no_delay":true,
"plugin":"/etc/shadowsocks-libev/",
"plugin_opts":"server"
}
{ "server":"0.0.0.0", "server_port":80, "password":"PASSWORD", "timeout":300, "user":"nobody", "method":"aes-256-gcm", "nameserver": "8.8.8.8", "fast_open":true, "reuse_port":true, "no_delay":true, "plugin":"/etc/shadowsocks-libev/", "plugin_opts":"server" }
{
    "server":"0.0.0.0",
    "server_port":80,
    "password":"PASSWORD",
    "timeout":300,
    "user":"nobody",
    "method":"aes-256-gcm",
    "nameserver": "8.8.8.8",
    "fast_open":true,
    "reuse_port":true,
    "no_delay":true,
    "plugin":"/etc/shadowsocks-libev/",
    "plugin_opts":"server"
}

References
https://github.com/M3chD09/shadowsocks-with-v2ray-plugin-install
https://gist.github.com/rampageX/134fa08a547d4b1eabd754c279b12676