去年末写过一篇简单而完整地体验一遍sentry的sourcemap服务, 是彻底基于使用层面的. 因为有需求须要自行搭建sentry, 整理一下搭建流程python
8.22.0 参考github releaselinux
官方推荐的方法是使用Docker, 咱们这里以使用Docker为例nginx
daocloud上附有教程, 请自行查阅git
$ docker --version
Docker version 18.05.0-ce, build f150324
$ docker-compose --version
docker-compose version 1.21.2, build a133471
复制代码
onpremise是官方提供的包含了sentry搭建所须要的所有依赖的引导程序github
$ git clone https://github.com/getsentry/onpremise.git
复制代码
$ cd onpremise
$ mkdir -p data/{sentry,postgres}
复制代码
这样须要说明一下, 我一开始没执行这一步操做, 虽然在构建过程当中程序会给咱们新建这些本该有的目录. 然而, 后续出现的一连串让人崩溃的问题, 譬如There was an error loading data
, 也会与此相关.web
secret key
$ docker-compose run --rm web config generate-secret-key
复制代码
这个时候会在终端输出redis
Starting onpremise_redis_1 ... done
Starting onpremise_postgres_1 ... done
Starting onpremise_memcached_1 ... done
xxx+5%xxxxxxx!!xxxxxxxx&6(xxxxxxx%xoml)xxxxxxxxxx
复制代码
复制秘钥(即最后一行)到docker-compose.yml中的SENTRY_SECRET_KEY
对应的valuedocker
$ docker-compose run --rm web upgrade
复制代码
正常的话, 终端会出现数据库
...
Would you like to create a user account now...
...
复制代码
正常键入便可segmentfault
在部署到linux机器上时, 出现过一种状况就是: 根本没出现这一步, 果断从头再来. 还好, 问题就此打住.
不像国内, 不少应用都支持邮件手机二选一的注册方式. 而sentry, 少了邮件功能, 就好像被阉割了同样, 也没什么好用的了.
在onpremise根目录里, 有一个config.yml配置文件, 里面定义了一些常规配置, 包括邮件配置方式.
# Use dummy if you want to disable email entirely
mail.backend: 'smtp'
mail.host: 'smtp.qq.com'
mail.port: 587
mail.username: '123@qq.com'
# 邮箱受权码, 非邮箱密码
mail.password: '123'
mail.use-tls: true
# The email address to send on behalf of
mail.from: '123@qq.com'
# 请保持与域名严格一致
mail.list-namespace: 'sentry.yourdomain.com'
复制代码
除了上述的注释外, 还有:
587
, 用465会出现一些奇怪的问题. sentry只支持tls而非ssh,因此端口改587试试$ docker-compose up -d
复制代码
如无心外, 一切正常, 端口默认是9000
, 本地的话能够直接打开localhost:9000
访问
官网上也有相关说明
配置https不要忽略了文档末段的修改sentry.conf.py
import os
import os.path
# 添加变量
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
复制代码
贴一下个人 nginx for https 配置
sentry.conf
server {
listen 80;
server_name sentry.yourdomain.com www.sentry.yourdomain.com;
location / {
if ($request_method = GET) {
rewrite ^ https://$host$request_uri? permanent;
}
return 405;
}
access_log /home/wwwlogs/sentry_yourdomain.log main;
}
server {
listen 443;
ssl on;
ssl_certificate /etc/nginx/ssl/yourdomain.crt;
ssl_certificate_key /etc/nginx/ssl/yourdomain.key;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_redirect off;
# keepalive + raven.js is a disaster
keepalive_timeout 0;
location / {
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
proxy_pass http://localhost:9000;
add_header Strict-Transport-Security "max-age=31536000";
}
access_log /home/wwwlogs/sentry_yourdomain.log main;
}
复制代码
首次须要配置Root URL等信息, 其中的Root URL填写https://sentry.yourdomain.com
便可, 不要填相似https://sentry.yourdomain.com/
这种, 貌似对从邮件中点击跳转等操做不友好.
团队内部使用可使用邮件邀请机制!!!!
结合文章开始介绍的简单而完整地体验一遍sentry的sourcemap服务, 能够体验一下本身搭建并使用sentry的快感!!!!