记录一下Xray用Trojan协议(兼容Trojan)+ Nginx伪装代理
安装Xray和Nginx
参考以下两个链接分别在服务器上安装Xray和Nginx。
编译安装和配置Nginx Xray官方Linux下安装指南
Nginx配置
编辑/etc/nginx/nginx.conf
, https的域名以weiyangbo.com为例
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73
| user root; worker_processes 1;
pid /var/run/nginx.pid; error_log /var/log/nginx_error.log;
events { use epoll; worker_connections 1024; multi_accept on; }
http { include /etc/nginx/mime.types; default_type application/octet-stream; charset ISO-88509-1; sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 60; client_header_buffer_size 4k; open_file_cache max=102400 inactive=20s; open_file_cache_valid 30s; open_file_cache_min_uses 1; client_header_timeout 15; client_body_timeout 15; reset_timedout_connection on; send_timeout 15; gzip on; gzip_disable "msie6"; gzip_vary on; gzip_proxied any; gzip_comp_level 3; gzip_buffers 16 8k; gzip_http_version 1.1; gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; server_tokens off; access_log /var/log/nginx_access.log;
server { listen 80 default_server; server_name weiyangbo.com www.weiyangbo.com; return 301 https://$server_name$request_uri; }
server { listen unix:/dev/shm/default.sock proxy_protocol; listen unix:/dev/shm/h2c.sock http2 proxy_protocol; charset ISO-88509-1; server_name weiyangbo.com www.weiyangbo.com; set_real_ip_from 127.0.0.1; add_header Strict-Transport-Security "max-age=63072000" always; root /root/mokee; location / { expires 10h; fancyindex on; fancyindex_exact_size off; fancyindex_localtime on; fancyindex_header "/fancyindex/header.html"; fancyindex_footer "/fancyindex/footer.html"; fancyindex_ignore "donate" "fancyindex" "Download"; fancyindex_name_length 500; } location ~* ^.+\.(jpg|gif|png|img|apk|tar.gz|wmv|jpeg|mp3|mp4|zip|rar)$ { valid_referers none blocked www.weiyangbo.com weiyangbo.com; if ($invalid_referer){ return 403; break; } access_log off; } } }
|
sudo systemctl restart nginx
Xray配置
编辑/usr/local/etc/xray/config.json
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| { "log": { "loglevel": "warning" }, "inbounds": [ { "port": 443, "protocol": "trojan", "settings": { "clients": [ { "password":"填你的密码" } ], "fallbacks": [ { "dest": "/dev/shm/default.sock", "xver": 1 }, { "alpn": "h2", "dest": "/dev/shm/h2c.sock", "xver": 1 } ] }, "streamSettings": { "network": "tcp", "security": "tls", "tlsSettings": { "alpn":["http/1.1","h2"], "certificates": [ {//自己搞定域名和证书 "certificateFile": "/etc/nginx/cert/2994039_weiyangbo.com.pem", "keyFile": "/etc/nginx/cert/2994039_weiyangbo.com.key" } ] } } } ], "outbounds": [ { "protocol": "freedom" } ] }
|
sudo systemctl restart xray