Skip to content

Instantly share code, notes, and snippets.

@jinyu121
Last active March 7, 2023 16:47
Show Gist options
  • Save jinyu121/8953505aa42832e75ceecf05fd3e2fd3 to your computer and use it in GitHub Desktop.
Save jinyu121/8953505aa42832e75ceecf05fd3e2fd3 to your computer and use it in GitHub Desktop.
V2Ray: VMess over apache TLS
<VirtualHost *:80>
ServerName your.domain
ServerAdmin admin@your.domain
DocumentRoot /var/www/v2proxy/
ErrorLog ${APACHE_LOG_DIR}/error-v2proxy.log
CustomLog ${APACHE_LOG_DIR}/access-v2proxy.log combined
php_admin_value open_basedir "/var/www/v2proxy/:/tmp/:/proc/"
<Directory /var/www/v2proxy>
Options FollowSymLinks
AllowOverride None
Require all granted
Order deny,allow
Allow from all
</Directory>
ProxyRequests Off
<Proxy /proxy>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /proxy/ ws://127.0.0.1:12306/
ProxyPassReverse /proxy/ ws://127.0.0.1:12306/
</VirtualHost>

Path

Let's call the path behid domain in URL FullPath, call the ProxyPass in apache_v2proxy.conf as BasePath.

The path in v2ray_server.config should be FullPath minus BasePath, while in v2ray_client.config, it should be FullPath.

For example:

  • URL: http://your.domain/path/to/v2ray/
  • The FullPath: /path/to/v2ray/
  • The BasePath: /path/
  • Path in v2ray_server.json: /to/v2ray
  • Path in v2ray_client.json: /path/to/v2ray/
# Enable Mod Proxy
sudo a2enmod proxy
sudo a2enmod proxy_html
sudo a2enmod proxy_wstunnel
sudo a2enmod ssl
sudo a2enmod rewrite
# Enable site
sudo mkdir -p /var/www/v2proxy
touch /var/www/v2proxy/index.html
sudo a2ensite v2proxy
# Let's Encrypt
# > Please follow the [instruction](https://letsencrypt.org/) to enable SSL.
{
"log": {
"error": "/var/log/v2ray/error.log",
"loglevel": "error"
},
"inbound": {
"port": 1080,
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {
"auth": "noauth",
"udp": false,
"ip": "0.0.0.0"
}
},
"outbound": {
"protocol": "vmess",
"settings": {
"vnext": [{
"address": "your.domain",
"port": 443,
"users": [{
"id": "00000000-0000-0000-0000-000000000000",
"alterId": 64,
"security": "auto"
}]
}]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/proxy/"
},
"security": "tls",
"tlsSettings": {
"serverName": "your.domain",
"allowInsecure": false
}
}
},
"outboundDetour": [{
"protocol": "freedom",
"settings": {},
"tag": "direct"
}],
"dns": {
"servers": [
"8.8.8.8",
"8.8.4.4",
"208.67.222.222",
"208.67.220.220",
"199.85.126.10",
"199.85.127.10",
"2001:4860:4860::8888",
"2001:4860:4860::8844",
"localhost"
]
},
"routing": {
"strategy": "rules",
"settings": {
"domainStrategy": "IPIfNonMatch",
"rules": [{
"type": "chinasites",
"outboundTag": "direct"
},
{
"type": "chinaip",
"outboundTag": "direct"
},
{
"type": "field",
"ip": [
"0.0.0.0/8",
"10.0.0.0/8",
"100.64.0.0/10",
"127.0.0.0/8",
"169.254.0.0/16",
"172.16.0.0/12",
"192.0.0.0/24",
"192.0.2.0/24",
"192.168.0.0/16",
"198.18.0.0/15",
"198.51.100.0/24",
"203.0.113.0/24",
"::1/128",
"fc00::/7",
"fe80::/10"
],
"outboundTag": "direct"
}
]
}
}
}
{
"log": {
"access": "/var/log/v2ray/access.log",
"error": "/var/log/v2ray/error.log",
"loglevel": "warning"
},
"inbound": {
"protocol": "vmess",
"port": "12306",
"listen": "127.0.0.1",
"settings": {
"clients": [{
"id": "00000000-0000-0000-0000-000000000000",
"alterId": 64
}]
},
"streamSettings": {
"network": "ws",
"wsSettings": {
"path": "/"
}
}
},
"outbound": {
"protocol": "freedom",
"settings": {}
},
"outboundDetour": [{
"protocol": "blackhole",
"settings": {},
"tag": "blocked"
}],
"routing": {
"strategy": "rules",
"settings": {
"rules": [{
"type": "field",
"ip": [
"0.0.0.0/8",
"10.0.0.0/8",
"100.64.0.0/10",
"127.0.0.0/8",
"169.254.0.0/16",
"172.16.0.0/12",
"192.0.0.0/24",
"192.0.2.0/24",
"192.168.0.0/16",
"198.18.0.0/15",
"198.51.100.0/24",
"203.0.113.0/24",
"::1/128",
"fc00::/7",
"fe80::/10"
],
"outboundTag": "blocked"
}]
}
}
}
@kevinlapus
Copy link

i am using putty can you teach me how to implent this
can you give me the step by step script in order t add v2ray appache proxy on my vps

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