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

2022/2/5 6:13:59

本文主要是介绍Django个人博客搭建教程---基于dwebsocket的实时日志系统,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

requirement

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

dwebsocket的配置与HTTPS部署

安装uwsgi

pip install uwsgi

uwsgi.ini

[uwsgi] 
chdir = /home/MyBlog 
module = MyBlog.wsgi:application 
socket = 127.0.0.1:8000
master = true 
processes = 1
threads = 2
max-requests = 6000
chmod-socket    = 666
buffer-size    = 65535
logto = /var/log/MyBlog.log
pidfile=/home/MyBlog/uwsgi.pid
ugreen =''
http-timeout = 300
enable-threads = true
stats = :3031
stats-http = true
#plugins=python
DJANGO_SETTINGS_MODULE=MyBlog.settings
WEBSOCKET_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实时日志

效果

 



这篇关于Django个人博客搭建教程---基于dwebsocket的实时日志系统的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!


扫一扫关注最新编程教程