如何让 Pasterserve 同时服务 HTTP 和 HTTPS 请求?

发布于 2024-09-12 04:19:27 字数 1360 浏览 7 评论 0原文

目前,我在 pylons 的项目配置中有以下几行:

[server:main]
...
ssl_pem = /path-to-pem/file-name.pem

因此 Paster 仅提供 HTTPS 请求,但不提供 HTTP 请求。任何 HTTP 请求都会在 Paster 调试控制台中导致以下异常:

Traceback (most recent call last):
  File "/home/eigenein/Projects/Python/Pylons/lib/python2.6/site-packages/Paste-1.7.4-py2.6.egg/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.6/SocketServer.py", line 320, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.6/SocketServer.py", line 615, in __init__
    self.handle()
  File "/home/eigenein/Projects/Python/Pylons/lib/python2.6/site-packages/Paste-1.7.4-py2.6.egg/paste/httpserver.py", line 442, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.6/BaseHTTPServer.py", line 329, in handle
    self.handle_one_request()
  File "/home/eigenein/Projects/Python/Pylons/lib/python2.6/site-packages/Paste-1.7.4-py2.6.egg/paste/httpserver.py", line 431, in handle_one_request
    self.raw_requestline = self.rfile.readline()
  File "/usr/lib/python2.6/socket.py", line 406, in readline
    data = self._sock.recv(self._rbufsize)
Error: [('SSL routines', 'SSL23_GET_CLIENT_HELLO', 'http request')]

是否也可以设置 Paster 来处理 HTTP 请求?

For now I have the following lines in a project configuration on pylons:

[server:main]
...
ssl_pem = /path-to-pem/file-name.pem

so paster serves only HTTPS requests but not HTTP. Any HTTP request causes the following exception in paster debug console:

Traceback (most recent call last):
  File "/home/eigenein/Projects/Python/Pylons/lib/python2.6/site-packages/Paste-1.7.4-py2.6.egg/paste/httpserver.py", line 1068, in process_request_in_thread
    self.finish_request(request, client_address)
  File "/usr/lib/python2.6/SocketServer.py", line 320, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.6/SocketServer.py", line 615, in __init__
    self.handle()
  File "/home/eigenein/Projects/Python/Pylons/lib/python2.6/site-packages/Paste-1.7.4-py2.6.egg/paste/httpserver.py", line 442, in handle
    BaseHTTPRequestHandler.handle(self)
  File "/usr/lib/python2.6/BaseHTTPServer.py", line 329, in handle
    self.handle_one_request()
  File "/home/eigenein/Projects/Python/Pylons/lib/python2.6/site-packages/Paste-1.7.4-py2.6.egg/paste/httpserver.py", line 431, in handle_one_request
    self.raw_requestline = self.rfile.readline()
  File "/usr/lib/python2.6/socket.py", line 406, in readline
    data = self._sock.recv(self._rbufsize)
Error: [('SSL routines', 'SSL23_GET_CLIENT_HELLO', 'http request')]

Is it possible to set up paster to serve HTTP requests too?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

拒绝两难 2024-09-19 04:19:27

根据 Pylons FAQ,没有。

http://wiki.pylonshq.com/pages/viewpage.action?pageId= 13434886

这是相当旧的条目,但我找不到任何允许在未来版本中配置它的更改。

According to Pylons FAQ, no.

http://wiki.pylonshq.com/pages/viewpage.action?pageId=13434886

It's quite old entry, but I can't find any changes that would allow configure it in future versions.

败给现实 2024-09-19 04:19:27

一般来说,无论如何你都应该使用一些前端服务器,比如 nginx。让它处理 SSL/非 SSL,然后通过 http/wsgi/fcgi 将请求传递给 Paster。

Generally, you should use some front-end server anyway, like nginx. Let it handle both SSL/Non-SSL, and then pass requests to paster over http/wsgi/fcgi.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文