Box
Box

trojan and nginx to using web service

** Using trojan+nginx reachs that pretending a normal website to be a proxy service **

first of all, we should know that the trojan forwards the all unknown packets to the remote port, the default remote port is 80. It’s a nice design for us to setting the environment.

if(packets is trojan)
{ do proxy service}
else
{ forwarding packets to port 80 }

so, it’s easy to achieve it that we just configure the web server.
My web server is using Nginx, the fllowing is configuration which I have configured.

configuration file:

1
2
3
4
5
6
 server {
listen 0.0.0.0:80;
listen [::]:80;
server_name _;
return 301 https://$host$request_uri;
}

The first server is listening port 80 from all IP address. Its mission is redirecting all request to port 443(https).

1
2
3
4
5
6
7
8
9
server {
listen 127.0.0.1:80;
server_name _ www.example.com; #example domain
access_log /data/wwwlogs/access_nginx.log combined;
root /data/wwwroot/default;
index index.html index.htm index.php;
#error_page 404 /404.html;
#error_page 502 /502.html;
}

The second is listening localhost port 80, this server is accepting packets from trojan which is true https packets.