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

59 篇文章 3 订阅

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实时日志

效果

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值