nag*_*epu 5 python django ubuntu ssl https
我试图使用https运行服务器,所以我安装了django-sslserver,并如下运行。
python manage.py runsslserver --certificate /etc/ssl/certs/server.crt --key /etc/ssl/private/server.key 0.0.0.0:8000
Run Code Online (Sandbox Code Playgroud)
使用以上命令成功运行。我可以通过localhost:8000或进行访问127.0.0.1:8000,但无法通过192.168.2.13:8000此处访问192.168.2.13我的IP地址。
为什么我无法通过我的IP地址访问?
并且即使使用非8000端口启动服务器,也默认为8000。在下面的示例中,我使用了8014,但是将其8000作为默认值。
root@nagapavan-HP-ProBook-440-G2:/home/nagapavan/Downloads/celestial_NAS# python manage.py runsslserver --certificate /etc/ssl/certs/server.c --key /etc/ssl/private/server.key 127.0.0.1:8014
Validating models...
System check identified some issues:
WARNINGS:
NAS.UserProfile.user: (fields.W342) Setting unique=True on a ForeignKey has the same effect as using a OneToOneField.
HINT: ForeignKey(unique=True) is usually better served by a OneToOneField.
System check identified 1 issue (0 silenced).
October 06, 2015 - 13:21:40
Django version 1.8.4, using settings 'celestial_NAS.settings'
Starting development server at 127.0.0.1:8000/
Using SSL certificate: /etc/ssl/certs/server.crt
Using SSL key: /etc/ssl/private/server.key
Quit the server with CONTROL-C
Run Code Online (Sandbox Code Playgroud)
为什么将端口号8000作为默认端口?
我发现了另一个命令来启动服务器,如下所示。我可以提供IP地址和端口号。它按预期工作。但我能够与IP地址的访问,而是通过无法访问localhost:9000或者127.0.0.1:9000甚至我访问服务器我的本地系统本身。
做出上述声明的原因可能是什么?
而且,即使我能够使用来通过我的IP地址进行访问https://192.168.2.13:9000,也无法从位于同一网络中的远程系统(甚至可以相互ping通)访问服务器。
为什么我不能从同一网络中的远程系统访问服务器,我们是否需要进行任何配置文件更改?
python manage.py runsslserver --certificate /etc/ssl/certs/server.c --key /etc/ssl/private/server.key --addrport 192.168.2.13:9000
Run Code Online (Sandbox Code Playgroud)
注意:以上所有URI均通过https访问
添加我在启动sslserver时遇到的错误,如下所示:
是上述问题的原因吗?
----------------------------------------
----------------------------------------
Exception happened during processing of request from ('192.168.1.166', 56694)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 295, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 321, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 334, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 102, in __init__
super(WSGIRequestHandler, self).__init__(*args, **kwargs)
File "/usr/lib/python2.7/SocketServer.py", line 649, in __init__
self.handle()
File "/usr/local/lib/python2.7/dist-packages/django/core/servers/basehttp.py", line 167, in handle
self.raw_requestline = self.rfile.readline(65537)
File "/usr/lib/python2.7/socket.py", line 476, in readline
data = self._sock.recv(self._rbufsize)
File "/usr/lib/python2.7/ssl.py", line 341, in recv
return self.read(buflen)
File "/usr/lib/python2.7/ssl.py", line 260, in read
return self._sslobj.read(len)
SSLError: [Errno 1] _ssl.c:1429: error:14094418:SSL routines:SSL3_READ_BYTES:tlsv1 alert unknown ca
----------------------------------------
----------------------------------------
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2310 次 |
| 最近记录: |