Forked from phlinhng/a-trojan-with-nginx-stream-module.md
Created
May 18, 2022 07:40
-
-
Save hitrust/7f7f56728baa8e96f70517147d63fca7 to your computer and use it in GitHub Desktop.
Revisions
-
phlinhng revised this gist
Sep 1, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -6,7 +6,7 @@ server { listen 127.0.0.1:80; server_name trojan.example.com; root /var/www/html; index index.php index.html index.htm; -
phlinhng revised this gist
Sep 1, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,4 @@ # 其他網站全部監聽 127.0.0.1:8443, 在這個端口進行 TLS 握手 # 將此檔案放到以下三種位置之一 # 位置1 (推荐): 放到 /etc/nginx/sites-available 下, 建立軟鏈到 /etc/nginx/sites-enabled # 位置2: 放到 /etc/nginx/conf.d -
phlinhng revised this gist
Aug 25, 2020 . 4 changed files with 8 additions and 8 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -8,15 +8,15 @@ stream { } upstream web { server 127.0.0.1:80; } upstream trojan { server 127.0.0.1:8080; } upstream tls_backend { server 127.0.0.1:8443; } server { This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,9 +1,9 @@ { "run_type": "server", "local_addr": "127.0.0.1", "local_port": 8080, "remote_addr": "127.0.0.1", "remote_port": 80, "log_level": 5, "password": [ "your_awesome_password" This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ # 位置3: 放到 /etc/nginx/sites-enabled server { listen 127.0.0.1:80; server_name ; root /var/www/html; This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -5,7 +5,7 @@ # 位置3: 放到 /etc/nginx/sites-enabled server { listen 127.0.0.1:8443 ssl http2; server_name website1.example.com; ssl_certificate /path/to/fullchain.crt; @@ -17,7 +17,7 @@ server { } server { listen 127.0.0.1:8443 ssl http2; server_name website2.example.com; ssl_certificate /path/to/fullchain.crt; -
phlinhng revised this gist
Aug 25, 2020 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -3,7 +3,7 @@ stream { map $ssl_preread_server_name $backend_name { trojan.example.com trojan; website1.example.com tls_backend; website2.example.com tls_backend; default web; } -
phlinhng renamed this gist
Aug 25, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
phlinhng renamed this gist
Aug 25, 2020 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
phlinhng created this gist
Aug 25, 2020 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1 @@ 利用 NGINX 的 Stream 模塊 sni_preread 功能,可以做到讓 Trojan 和其他網站在同一台機器上共享 443 端口。 This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,8 @@ # 將 /etc/nginx/sites-available/default 的內容改成如下,可以實現全局 https 跳轉 server { listen 80 default_server; listen [::]:80 default_server; server_name _; return 301 https://$host$request_uri; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,28 @@ # 在 /etc/nginx/nginx.conf 加入這段, 原先的內容不要刪 stream { map $ssl_preread_server_name $backend_name { trojan.example.com trojan; website1.example.com tls_backend; website2.example.com tls_backend; default web; } upstream web { server 127.0.0.1:8080; } upstream trojan { server 127.0.0.1:8081; } upstream tls_backend { server 127.0.0.1:8082; } server { listen 443 reuseport; listen [::]:443 reuseport; proxy_pass $backend_name; ssl_preread on; } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ { "run_type": "server", "local_addr": "127.0.0.1", "local_port": 8081, "remote_addr": "127.0.0.1", "remote_port": 8080, "log_level": 5, "password": [ "your_awesome_password" ], "ssl": { "verify_hostname": true, "cert": "/etc/ssl/trojan/fullchain.crt", "key": "/etc/ssl/trojan/key.key", "sni": "trojan.example.com", "alpn": [ "http/1.1" ] }, "router": { "enabled": false } } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,13 @@ # trojan 偽裝站設置 # 將此檔案放到以下三種位置之一 # 位置1 (推荐): 放到 /etc/nginx/sites-available 下, 建立軟鏈到 /etc/nginx/sites-enabled # 位置2: 放到 /etc/nginx/conf.d # 位置3: 放到 /etc/nginx/sites-enabled server { listen 127.0.0.1:8080; server_name ; root /var/www/html; index index.php index.html index.htm; } This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,29 @@ # 其他網站全部監聽 127.0.0.1:8082, 在這個端口進行 TLS 握手 # 將此檔案放到以下三種位置之一 # 位置1 (推荐): 放到 /etc/nginx/sites-available 下, 建立軟鏈到 /etc/nginx/sites-enabled # 位置2: 放到 /etc/nginx/conf.d # 位置3: 放到 /etc/nginx/sites-enabled server { listen 127.0.0.1:8082 ssl http2; server_name website1.example.com; ssl_certificate /path/to/fullchain.crt; ssl_certificate_key /path/to/key.key; ssl_protocols TLSv1.2 TLSv1.3; location / { } } server { listen 127.0.0.1:8082 ssl http2; server_name website2.example.com; ssl_certificate /path/to/fullchain.crt; ssl_certificate_key /path/to/key.key; ssl_protocols TLSv1.2 TLSv1.3; location / { } }