从零搭建博客之运营维护

从零搭建博客之运营维护

2021年06月02日 阅读:41 字数:586 阅读时长:2 分钟

使用Easy-Monitor,对显示Node.js应用进行监控调优

1.SEO优化

利用搜索引擎的规则提高网站在有关搜索引擎内自然排名,咋也没必要竞价排名。

主要是使用nuxt的head属性,给每个页面、文章添加标题、关键字和描述

head () {
  return {
    title: this.meta.title,
    meta: [
      { hid: 'description', name: 'description', content: this.meta.description },
      { hid: 'keyword', name: 'keyword', content: this.meta.keyword }
    ]
  }
},

友情链接:与别的网站交换链接,增加网站被访问的概率。

加入十年之约,可以通过https://www.foreverblog.cn/go.html,随机访问成员网站。

2.监控预警

阿里的Node.js性能平台(下文简称Alinode) 本地 windows 开发环境,window server 生产环境下无法使用。需要用Alinode代替Node,Runtime 的更新可能跟不上Node.js runtime,且不能私有化部署。

Easy-Monitor的作者也是Alinode团队的成员,项目功能一样强大,且基于 Node.js Addon 实现,不需要替换Node。部署需要一定的动手能力。

2.1.Easy-Monitor

https://www.yuque.com/hyj1991/easy-monitor/

控制台:

实例首页:

系统监控:

性能数据:

GC追踪日志分析:

堆快照分析:

诊断报告:

CPU火焰图:

有一些前置外部依赖 MySQL、Redis

2.2.性能日志插件

启动入口文件production.js

require('xprofiler').start();
const path = require('path')
const Application = require('thinkjs')

const instance = new Application({
  ROOT_PATH: __dirname,
  APP_PATH: path.join(__dirname, 'src'),
  proxy: true, // use proxy
  env: 'production'
})

instance.run()

2.3.日志采集器

thinkjs建议使用全局方式启动,不能像日志插件那样放到production.js中,因为线上一般会启动多个业务进程

xtransit start ./config.js

3.网站安全

3.1.XSS 攻击

对 Web 页面注入脚本,使用 JavaScript 窃取用户信息,诱导用户操作。

对用户输入对进行转义、过滤,主要是网站评论功能

const xss = require('xss');

const data = this.post();
xss(data.content)

校验层限制提交内容长度

this.rules = {
  name: {
    required: true,
    length: { max: 50 }
  },
  email: {
    email: true,
    length: { max: 255 }
  },
  website: {
    fqdn: true,
    length: { max: 255 }
  },
  content: {
    required: true,
    length: { max: 500 }
  }
}

3.2.DDOS 攻击

  • 启用网络防火墙
  • 限制QPS,包括网站以及CDN

  • 对象存储和CDN添加白名单以及防盗链

4.收支情况

支出:服务器平均150元/年;.com域名60~75元/年;其他的服务比如对象存储、CDN都有免费额度,基本不怎么花钱

共1300元左右

收入:

谷歌广告够100美元才能提现,只提过一次700多元

赞助95元

共800元左右

推荐阅读

恰饭区

评论区 (0)

0/500

还没有评论,快来抢第一吧