如何使nginx反向代理直接隐藏服务?

问题描述 投票:2回答:1

是否有可能通过隐藏服务获得clearnet网站隧道?例如,如果有人拥有blah.com并且它指向服务器IP 1.2.3.4,但希望1.2.3.4向隐藏服务发出代理请求。

重点是拥有一个clearnet“look”网站,同时将网站内容本身放在一个隐藏的服务器上,基本上是proxy_pass会做什么,除非它需要连接到localhost。

任何想法如何/可以做到这一点?

nginx service proxy hidden tor
1个回答
0
投票

您没有指定后端语言,因此我将向您展示使用python Django的示例。

假设您已经在服务器上配置了tor(而不是tor浏览器),您只需使用requests(或aiohttp,urllib2等)发出GET请求,然后将响应转发给您的客户端:

from django.shortcuts import render
import requests

def someView(req):
    url = 'someWebsite.onion'
    proxy = {
        'http':'socks5h://localhost:9050',
        'https':'socks5h://localhost:9050'
    }
    html = requests.get(url, proxy=proxy)
    context = {'html':html}
    return render(req, 'someTemplate.html', context)  

然后在someTemplate.html

{{ html }}

可能有更优雅的方法将html数据传递给您的客户端,但这在很大程度上取决于您使用的后端。

如果你不熟悉在本地机器上运行tor作为代理,你应该阅读这个here

在linux上:

  • 安装:apt install tor
  • 首发:tor

在mac上:

  • 安装:brew install tor(需要homebrew
  • 首发:tor

在Windows上:

  • 你是SOL xD。

我不知道如何在nginx服务器上配置tor代理,但这可能是一个很好的后续问题。

© www.soinside.com 2019 - 2024. All rights reserved.