欢迎您访问365答案网,请分享给你的朋友!
生活常识 学习资料

Django个人博客搭建教程---基于dwebsocket的实时日志系统

时间:2023-08-26
requirement

Django==2.1.7paramiko==2.7.1dwebsocket==0.5.12

dwebsocket的配置与HTTPS部署

安装uwsgi

pip install uwsgi

uwsgi.ini

[uwsgi] chdir = /home/MyBlog module = MyBlog.wsgi:application socket = 127.0.0.1:8000master = true processes = 1threads = 2max-requests = 6000chmod-socket = 666buffer-size = 65535logto = /var/log/MyBlog.logpidfile=/home/MyBlog/uwsgi.pidugreen =''http-timeout = 300enable-threads = truestats = :3031stats-http = true#plugins=pythonDJANGO_SETTINGS_MODULE=MyBlog.settingsWEBSOCKET_FACTORY_CLASS="dwebsocket.backends.uwsgi.factory.uWsgiWebSocketFactory"http-websockets=true

nginx.conf

server { listen 443 ssl http2 default_server ; listen [::]:443 default_server; server_name _; ssl on; ssl_certificate /etc/nginx/cert/7046953_guanacossj.com.pem; # 路径/pem文件 ssl_certificate_key /etc/nginx/cert/7046953_guanacossj.com.key; # 路径/key文件 ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ssl_prefer_server_ciphers on; charset utf-8; client_max_body_size 1000M; # adjust to taste include /etc/nginx/default.d/*.conf; location /static { alias /home/MyBlog/static; # ָÏdjangoµÄtaticĿ¼ } location /static/rest_framework/ { alias /usr/local/lib/python3.6/dist-packages/rest_framework/static/rest_framework/ ;} # Finally, send all non-media requests to the Django server. location / { uwsgi_pass 127.0.0.1:8000; include uwsgi_params; # the uwsgi_params file you installed; proxy_redirect off; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; uwsgi_send_timeout 600; uwsgi_connect_timeout 600; uwsgi_read_timeout 600; } }

settings.py

INSTALLED_APPS = [ ..., 'dwebsocket', ...]WEBSOCKET_FACTORY_CLASS = 'dwebsocket.backends.uwsgi.factory.uWsgiWebSocketFactory'

实时日志系统

GitHub - py3study/real_time_log: django查看linux实时日志

效果

 

Copyright © 2016-2020 www.365daan.com All Rights Reserved. 365答案网 版权所有 备案号:

部分内容来自互联网,版权归原作者所有,如有冒犯请联系我们,我们将在三个工作时内妥善处理。