在 nginx 中使用 proxy_pass 和socks5代理

MrC*_*neK 5 nginx socks

我想托管一个服务,然后在通过特定域访问该服务时使用特定代理连接到它。

就像这里显示的那样:

| # User make a request to s2.example.com
|__ s2.example.com <-- This is my VPS that runs debian sid, nginx and some websites hosted on example.com
|
|__ nginx receive request, and use 127.0.0.1:9050 as socks5 proxy, and send request to elpmaxe.onion
|
|__ 127.0.0.1:9050 receive request, and redirect it to target elpmaxe.onion
|
|__ elpmaxe.onion receive request, and send response
Run Code Online (Sandbox Code Playgroud)

// 我知道这会导致连接延迟,但这不是一个大问题。

为了解决我的问题,我想做这样的事情,但我只是不知道如何在执行 proxy_pass 时使用socks5。

location / {
  # using socks5 proxy on 127.0.0.1:9050
  proxy_pass http://elpmaxe.onion/;
}
Run Code Online (Sandbox Code Playgroud)