vue + tornado 个人博客项目简介

vue + tornado 个人博客项目简介

项目链接:https://www.freepd.top

项目链接:https://admin.freepd.top

项目简介

首页预览

本站接入了百度api

每小时更新访问量

域名在阿里云购买,解析到腾讯云服务器

ssl证书为阿里云每年免费申请20个

技术栈

前端: vue2 + element-ui + axios + vue-router

后端: python + mysql + tornado + peewee + redis + pydantic + JWT

项目结构

前端:

后端:

服务器环境

服务器配置为腾讯云:

轻量级服务器(2核2G 4M)

服务器环境为:

docker运行redis与mysql

后端服务启动为:

supervisor启动三个python tornado进程配置如下

supervisor配置:

nginx配置

复制代码
path: /etc/nginx/conf.d/pyblog.conf

配置如下

upstream prod_api {
    server 127.0.0.1:11111;
    server 127.0.0.1:22222;
    server 127.0.0.1:33333;
}



server {
    listen 80;
    #填写证书绑定的域名
    server_name "admin.freepd.top";
    #将所有HTTP请求通过rewrite指令重定向到HTTPS。
    rewrite ^(.*)$ https://$host$1;
    location / {
        index index.html index.htm;
    }
}



server {
    listen 80;
    #填写证书绑定的域名
    server_name www.freepd.top freepd.top;
    #将所有HTTP请求通过rewrite指令重定向到HTTPS。
    rewrite 301 https://$server_name$request_uri;
    location / {
        index index.html index.htm;
    }
}

server {
    listen       443 ssl;
    server_name  "api.freepd.top";
    client_max_body_size 10m;
    ssl_certificate "conf/pyblog/api.freepd.top.pem";
    ssl_certificate_key "conf/pyblog/api.freepd.top.key";
    ssl_session_timeout 5m;
    #表示使用的加密套件的类型
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    #表示使用的TLS协议的类型,您需要自行评估是否配置TLSv1.1协议。
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;

    ssl_prefer_server_ciphers on;

    location /api/ {

        add_header  Access-Control-Allow-Origin         $http_origin;
        add_header  Access-Control-Allow-Methods        *;
        add_header  Access-Control-Max-Age              756000; # 缓存30天
        add_header  Access-Control-Allow-Credentials    true;
        add_header  Access-Control-Allow-Headers        $http_access_control_request_headers;

        if ($request_method = OPTIONS) {
            return 204;
        }
        proxy_pass http://prod_api/;

        proxy_set_header Host $host;
        proxy_set_header X-Real-Ip $remote_addr;
        proxy_set_header X-Forwarded-For $remote_addr;
    }
}




server {
    listen       443 ssl http2;
    server_name  "admin.freepd.top";
    client_max_body_size 10m;
    ssl_certificate "conf/pyblog/admin.freepd.top.pem";
    ssl_certificate_key "conf/pyblog/admin.freepd.top.key";
    ssl_session_timeout 5m;
    #表示使用的加密套件的类型
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    #表示使用的TLS协议的类型,您需要自行评估是否配置TLSv1.1协议。
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;

    ssl_prefer_server_ciphers on;


    location / {
        root /home/ubuntu/run/pyblog/pyblog-admin;
        index index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

}

server {
    gzip on;
    gzip_static on;
    gzip_min_length 10k;
    #压缩级别1-9,越大压缩率越高,同时消耗cpu资源也越多,建议设置在5左右。
    gzip_comp_level 5;
    #需要压缩哪些响应类型的资源,多个空格隔开。不建议压缩图片.
    gzip_types text/plain application/javascript application/x-javascript text/javascript text/xml text/css;
    #配置禁用gzip条件,支持正则。此处表示ie6及以下不启用gzip(因为ie低版本不支持)
    gzip_disable "MSIE [1-6]\.";
    #是否添加"Vary: Accept-Encoding"响应头
    gzip_vary on;
    listen       443 ssl http2;
    server_name  www.freepd.top freepd.top;
    client_max_body_size 10m;
    ssl_certificate "conf/pyblog/www.freepd.top.pem";
    ssl_certificate_key "conf/pyblog/www.freepd.top.key";
    ssl_session_timeout 5m;
    #表示使用的加密套件的类型
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4;
    #表示使用的TLS协议的类型,您需要自行评估是否配置TLSv1.1协议。
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;

    ssl_prefer_server_ciphers on;


    location / {
        proxy_set_header Accept-Encoding 'gzip';
        root /home/ubuntu/run/pyblog/pyblog-show;
        index index.html index.htm;
        try_files $uri $uri/ /index.html;
    }

}
相关推荐
图书馆钉子户1 小时前
django orm的优缺点
后端·python·django
linuxxx1101 小时前
django报错:RuntimeError: populate() isn‘t reentrant
后端·python·django
@小匠1 小时前
使用 Python包管理工具 uv 完成 Open WebUI 的安装
开发语言·python·uv
网络风云2 小时前
Flask(七)用户认证与权限管理
后端·python·flask
船长@Quant2 小时前
PyTorch量化技术教程:第四章 PyTorch在量化交易中的应用
pytorch·python·深度学习·机器学习·量化交易·ta-lib
MobiCetus2 小时前
如何一键安装所有Python项目的依赖!
开发语言·jvm·c++·人工智能·python·算法·机器学习
kcarly2 小时前
python 、pip、conda、poetry的关系
python·conda·pip·poetry
朴拙数科2 小时前
Python命名规范与代码最优结构规范:提升PyCharm中的可读性与健壮性
开发语言·python·pycharm
Bruce_Liuxiaowei3 小时前
DeepSeek API集成开发指南——Flask示例实践
后端·python·flask·deepseek
TPCloud3 小时前
如何快速解决django存储session变量时出现的django.db.utils.DatabaseError错误
数据库·python·django