Configuration Guide

Hướng dẫn chi tiết về cách cấu hình ProxVN Client qua config file, flags và environment variables.

Configuration Precedence

Client đọc cấu hình theo thứ tự ưu tiên từ cao xuống thấp:

  1. CLI Flags (cao nhất — override mọi thứ)
  2. Config File (proxvn.json)
  3. Built-in Defaults (thấp nhất)
Ví dụ: Nếu config file có "proto": "tcp" nhưng bạn chạy ./proxvn --proto http, client sẽ dùng http (flag > file).

Config File (proxvn.json)

Vị trí tìm kiếm

Client tự động tìm proxvn.json ở các vị trí sau (thứ tự ưu tiên):

  1. --config /path/to/custom.json (nếu chỉ định)
  2. Environment variable PROXVN_CONFIG
  3. Thư mục chứa binary
  4. Thư mục hiện tại (cwd)
  5. ~/.proxvn/proxvn.json

JSON Schema

{
"server": "103.77.246.196:8882",
"proto": "tcp",
"host": "localhost",
"port": 8080,
"ui": true,
"cert_pin": "29e1546abeb0e1d27adc57362422670b5347a0f19a847c5e9dda8fa7cd99c6d8",
"insecure": false
}

Các trường (Fields)

Field Type Default Mô tả
server string 103.77.246.196:8882 Địa chỉ server tunnel (IP:Port)
proto string tcp Giao thức: tcp, udp, http
host string localhost Host local cần forward
port int 80 Port local
ui bool true Bật giao diện TUI (false = background mode)
cert_pin string "" SHA256 cert pin để xác thực server
insecure bool false Bỏ qua xác thực SSL (chỉ dùng test)

Use Case Examples

Development Workflow

Dùng config file để không phải gõ lại flag mỗi lần:

# proxvn.json
{
"proto": "http",
"port": 3000,
"ui": true
}

# Chạy
./proxvn # tự động dùng config

Production Server (Background)

# proxvn.json
{
"server": "103.77.246.196:8882",
"proto": "tcp",
"port": 22,
"ui": false,
"cert_pin": "29e1546abeb0e1d27adc57362422670b5347a0f19a847c5e9dda8fa7cd99c6d8"
}

# Chạy bằng systemd hoặc nohup
nohup ./proxvn > tunnel.log 2>&1 &

Multiple Tunnels

Tạo nhiều config file cho từng tunnel:

# web.json
{ "proto": "http", "port": 3000 }

# ssh.json
{ "proto": "tcp", "port": 22 }

# Chạy song song
./proxvn --config web.json &
./proxvn --config ssh.json &

Security Best Practices

Luôn dùng Certificate Pinning

Cert pin của server free public:

29e1546abeb0e1d27adc57362422670b5347a0f19a847c5e9dda8fa7cd99c6d8

Thêm vào config:

{
"cert_pin": "29e1546abeb0e1d27adc57362422670b5347a0f19a847c5e9dda8fa7cd99c6d8"
}

Không commit config có thông tin nhạy cảm

Nếu config chứa API key, token... thêm vào .gitignore:

# .gitignore
proxvn.json
*.local.json

Environment Variables

Hiện tại client hỗ trợ:

Variable Mô tả
PROXVN_CONFIG Đường dẫn đến config file custom

Ví dụ

export PROXVN_CONFIG=/etc/proxvn/production.json
./proxvn

Advanced: Override per run

Config file + flags kết hợp linh hoạt:

# Config file: proto=tcp, port=22
# Nhưng lần này muốn HTTP port 3000:
./proxvn --proto http 3000

# Kết quả: proto=http, port=3000 (flags win)

← Back to HomeCLI Reference