This is a copy of a chat between Claude and myf. Content may include unverified or unsafe content that do not represent the views of Anthropic. Shared snapshot may contain attachments and data not displayed here.
Give me step by step instructions on how to setup trojan client/server to bypass censorship. Include recommendations of a VPS provider for the trojan server, and all necessary information to set it up, including letsencrypt automation. Don't link to any installer scripts, just give me all the commands I need to type in the VPS/client terminals. Assume Ubuntu 22.04 for both client and server.
I'll help you set up a Trojan proxy for censorship circumvention. Trojan is a legitimate privacy tool that disguises traffic as HTTPS, making it effective against deep packet inspection.
For reliable service with good global connectivity:
Choose a location geographically close to your actual location but outside censorship zones.
# Update system
sudo apt update && sudo apt upgrade -y
# Install required packages
sudo apt install -y wget curl nginx certbot python3-certbot-nginx ufw
# Configure firewall
sudo ufw default deny incoming
sudo ufw default allow outgoing
sudo ufw allow ssh
sudo ufw allow 80/tcp
sudo ufw allow 443/tcp
sudo ufw enableYou'll need a domain name. Point it to your VPS IP address via DNS A record.
# Configure nginx for your domain (replace example.com)
sudo nano /etc/nginx/sites-available/defaultReplace the contents with:
server {
listen 80;
server_name your-domain.com;
root /var/www/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}# Enable site and restart nginx
sudo nginx -t
sudo systemctl restart nginx
# Get SSL certificate
sudo certbot --nginx -d your-domain.com
# Set up auto-renewal
sudo crontab -eAdd this line to crontab:
0 12 * * * /usr/bin/certbot renew --quiet# Download trojan-go
cd /tmp
wget https://github.com/p4gefau1t/trojan-go/releases/latest/download/trojan-go-linux-amd64.zip
unzip trojan-go-linux-amd64.zip
# Move binary
sudo mv trojan-go /usr/local/bin/
sudo chmod +x /usr/local/bin/trojan-go
# Create trojan user
sudo useradd -r -s /bin/false trojan
# Create directories
sudo mkdir -p /etc/trojan-go
sudo mkdir -p /var/log/trojan-go
sudo chown trojan:trojan /var/log/trojan-go# Create server config
sudo nano /etc/trojan-go/server.jsonInsert this configuration (replace placeholders):
{
"run_type": "server",
"local_addr": "0.0.0.0",
"local_port": 443,
"remote_addr": "127.0.0.1",
"remote_port": 80,
"password": ["YOUR_STRONG_PASSWORD_HERE"],
"ssl": {
"cert": "/etc/letsencrypt/live/your-domain.com/fullchain.pem",
"key": "/etc/letsencrypt/live/your-domain.com/privkey.pem",
"sni": "your-domain.com"
},
"websocket": {
"enabled": true,
"path": "/your-secret-path",
"host": "your-domain.com"
},
"log_level": 1,
"log_file": "/var/log/trojan-go/server.log"
}sudo nano /etc/systemd/system/trojan-go.serviceInsert:
[Unit]
Description=Trojan-Go Server
After=network.target
[Service]
Type=simple
User=trojan
ExecStart=/usr/local/bin/trojan-go -config /etc/trojan-go/server.json
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.target# Set permissions
sudo chown -R trojan:trojan /etc/trojan-go
# Start and enable service
sudo systemctl daemon-reload
sudo systemctl enable trojan-go
sudo systemctl start trojan-go
# Check status
sudo systemctl status trojan-gosudo nano /etc/nginx/sites-available/defaultReplace with this fallback configuration:
server {
listen 80;
server_name your-domain.com;
return 301 https://$server_name$request_uri;
}
server {
listen 127.0.0.1:80;
server_name your-domain.com;
root /var/www/html;
index index.html;
location / {
try_files $uri $uri/ =404;
}
}sudo nginx -t
sudo systemctl restart nginx# Download and install
cd /tmp
wget https://github.com/p4gefau1t/trojan-go/releases/latest/download/trojan-go-linux-amd64.zip
unzip trojan-go-linux-amd64.zip
sudo mv trojan-go /usr/local/bin/
sudo chmod +x /usr/local/bin/trojan-go
# Create directories
mkdir -p ~/.config/trojan-gonano ~/.config/trojan-go/client.jsonInsert:
{
"run_type": "client",
"local_addr": "127.0.0.1",
"local_port": 1080,
"remote_addr": "your-domain.com",
"remote_port": 443,
"password": ["YOUR_STRONG_PASSWORD_HERE"],
"ssl": {
"sni": "your-domain.com"
},
"websocket": {
"enabled": true,
"path": "/your-secret-path",
"host": "your-domain.com"
},
"log_level": 1
}# Test connection
trojan-go -config ~/.config/trojan-go/client.json
# Create systemd service (optional)
sudo nano /etc/systemd/system/trojan-client.serviceService file content:
[Unit]
Description=Trojan-Go Client
After=network.target
[Service]
Type=simple
User=%i
ExecStart=/usr/local/bin/trojan-go -config /home/%i/.config/trojan-go/client.json
Restart=on-failure
RestartSec=5s
[Install]
WantedBy=multi-user.targetAfter starting the client, configure your applications to use SOCKS5 proxy at 127.0.0.1:1080.
/var/log/trojan-go/server.log regularly# Test SOCKS5 proxy (with client running)
curl --socks5 127.0.0.1:1080 https://httpbin.org/ipThis setup creates a robust censorship circumvention tool. Remember to comply with local laws and use responsibly. The Trojan protocol's strength lies in its ability to appear as regular HTTPS traffic, making detection difficult whilst maintaining good performance.