[英]Twisted reverse proxy SSL backend
我是Twisted的新手,並嘗試利用twisted.web.proxy.ReverseProxyResource創建反向代理。 最終,我希望客戶端使用SSL連接到它,然后驗證請求,並將其僅傳遞給SSL后端服務器。 我從下面的(非常)基本代碼開始,但是努力使它連接到SSL后端,並且發現缺少文檔。 誰能給我一些好的指針,或者理想情況下提供一些示例代碼?
在下面的代碼中,它顯然無法正常工作,因為它希望到達普通的HTTP服務器,我將如何對其“ ssl”呢?
一如既往,任何幫助都是非常非常感謝的。
謝謝
亞歷克斯
from twisted.internet import reactor
from twisted.web import proxy, server
from twisted.web.resource import Resource
class Simple(Resource):
isLeaf = False
def getChild(self, name, request):
print "getChild called with name:'%s'" % name
#host = request.getAllHeaders()['host']
host = "127.0.0.1" #yes there is an SSL host listening here
return proxy.ReverseProxyResource(host, 443, "/"+name)
simple = Simple()
site = server.Site(simple)
reactor.listenTCP(8000, site)
reactor.run()
ReverseProxyResource
不支持TLS。 當您編寫ReverseProxyResource(host, 443, "/"+name)
您正在創建一個資源,該資源將在端口443上建立到host
的正常TCP連接。TCP連接嘗試將成功,但是TLS握手肯定會失敗-因為客戶甚至不會嘗試。
這是當前ReverseProxyResource
的限制:它不支持您想要的功能。 此功能可能很容易實現。 自從實現ReverseProxyResource
以來,Twisted引入了“端點”的概念,這使編寫與傳輸無關的代碼變得更加容易。
可以更新ReverseProxyResource
以使其在“端點”方面起作用(盡管Twisted要求保留與當前API的向后兼容性)。 這並不會使實現復雜化很多(實際上可能會簡化它),並且可以讓您代理存在終結點實現的任何類型的傳輸(TLS有一個實現,還有更多種)。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.