Last active
May 17, 2022 09:45
-
-
Save outiy5/57cb1a824a0c6d2dd527fb7f3e6be121 to your computer and use it in GitHub Desktop.
Revisions
-
outiy5 revised this gist
May 17, 2022 . 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 @@ -48,6 +48,6 @@ sudo python reverse_proxy.py https://stackoverflow.com/questions/38766244/pyopenssl-twisted-with-lets-encrypt-servers-certificate-chain-is-incomplete twisted letsencrypt. https://twistedmatrix.com/documents/current/web/examples/ reverse proxy. https://twistedmatrix.com/documents/current/core/howto/ssl.html https. twisted ssl. https://twistedmatrix.com/documents/13.1.0/core/examples/index.html examples. https://stackoverflow.com/questions/35664007/python-twisted-reverse-proxy-to-https-api-could-not-connect proxy to https url. -
outiy5 revised this gist
May 17, 2022 . 1 changed file with 1 addition and 0 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 @@ -50,3 +50,4 @@ https://stackoverflow.com/questions/38766244/pyopenssl-twisted-with-lets-encrypt https://twistedmatrix.com/documents/current/web/examples/ reverse proxy. https://twistedmatrix.com/documents/current/core/howto/ssl.html https. https://twistedmatrix.com/documents/13.1.0/core/examples/index.html examples. https://stackoverflow.com/questions/35664007/python-twisted-reverse-proxy-to-https-api-could-not-connect proxy to https url. -
outiy5 revised this gist
May 17, 2022 . 1 changed file with 4 additions and 0 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 @@ -22,6 +22,10 @@ reactor.listenSSL(443, site, contextFactory) reactor.run() ``` ## HTTPS to HTTPS Just implement one more factory for `proxy.ReverseProxyResource("127.0.0.1", 8000, b"")` to apply to https connections. See references for examples. I would update this part later. ## HTTP to HTTP ``` -
outiy5 revised this gist
May 17, 2022 . 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 @@ -10,7 +10,7 @@ from twisted.web import proxy, server log.startLogging(sys.stdout) from OpenSSL import crypto privkey=open('privkey.pem', 'rt').read() # copy letsencrypt certficates here certif=open('cert.pem', 'rt').read() chain=open('chain.pem', 'rt').read() privkeypyssl=crypto.load_privatekey(crypto.FILETYPE_PEM,privkey) -
outiy5 revised this gist
May 17, 2022 . No changes.There are no files selected for viewing
-
outiy5 revised this gist
May 17, 2022 . 1 changed file with 2 additions and 2 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 @@ -42,7 +42,7 @@ sudo python reverse_proxy.py ## Reference https://stackoverflow.com/questions/38766244/pyopenssl-twisted-with-lets-encrypt-servers-certificate-chain-is-incomplete twisted letsencrypt. https://twistedmatrix.com/documents/current/web/examples/ reverse proxy. https://twistedmatrix.com/documents/current/core/howto/ssl.html https. https://twistedmatrix.com/documents/13.1.0/core/examples/index.html examples. -
outiy5 revised this gist
May 17, 2022 . 1 changed file with 4 additions and 4 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 @@ -42,7 +42,7 @@ sudo python reverse_proxy.py ## Reference https://stackoverflow.com/questions/38766244/pyopenssl-twisted-with-lets-encrypt-servers-certificate-chain-is-incomplete twisted letsencrypt. https://twistedmatrix.com/documents/current/web/examples/ reverse proxy https://twistedmatrix.com/documents/current/core/howto/ssl.html https. https://twistedmatrix.com/documents/13.1.0/core/examples/index.html examples. -
outiy5 revised this gist
May 17, 2022 . 1 changed file with 2 additions and 0 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 @@ -35,8 +35,10 @@ reactor.run() ## Dependencies ``` sudo pip install service_identity twisted sudo python reverse_proxy.py ``` ## Reference -
outiy5 created this gist
May 17, 2022 .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,46 @@ ## HTTPS to HTTP `reverse_proxy.py`: ``` import sys from twisted.internet import ssl, protocol, task, defer from twisted.python import log from twisted.internet import reactor from twisted.web import proxy, server log.startLogging(sys.stdout) from OpenSSL import crypto privkey=open('privkey.pem', 'rt').read() # copy letsencrypt cerficate here certif=open('cert.pem', 'rt').read() chain=open('chain.pem', 'rt').read() privkeypyssl=crypto.load_privatekey(crypto.FILETYPE_PEM,privkey) certifpyssl=crypto.load_certificate(crypto.FILETYPE_PEM,certif) chainpyssl=[crypto.load_certificate(crypto.FILETYPE_PEM,chain)] contextFactory=ssl.CertificateOptions(privateKey=privkeypyssl,certificate=certifpyssl,extraCertChain=chainpyssl) site = server.Site(proxy.ReverseProxyResource("127.0.0.1", 8000, b"")) reactor.listenSSL(443, site, contextFactory) reactor.run() ``` ## HTTP to HTTP ``` from twisted.internet import reactor from twisted.web import proxy, server site = server.Site(proxy.ReverseProxyResource("example.com", 80, b"")) reactor.listenTCP(8080, site) reactor.run() ``` ## Dependencies sudo pip install service_identity twisted sudo python reverse_proxy.py ## Reference https://stackoverflow.com/questions/38766244/pyopenssl-twisted-with-lets-encrypt-servers-certificate-chain-is-incomplete twisted letsencrypt https://twistedmatrix.com/documents/current/web/examples/ reverse proxy https://twistedmatrix.com/documents/current/core/howto/ssl.html https https://twistedmatrix.com/documents/13.1.0/core/examples/index.html examples