您的位置:首页 > 其它

在Ubuntu 16.04 LTS安装Mattermost(二)

2017-07-29 17:01 381 查看
在Ubuntu 16.04 LTS安装Mattermost(一)
在Ubuntu 16.04 LTS安装Mattermost(二)

配置Mattermost
创建系统管理员用户,设置Mattermost的一般用途

.打开浏览器,导航到Mattermost实例.比如:Mattermost服务器IP地址为10.10.10.10,然后访问http://10.10.10.10:8065.
.创建第一个团队和用户,第一个用户是系统管理员(system_admin)角色,有权限访问系统控制台

.打开系统控制台.点击导航面板顶部的用户名,在打开的菜单中,点击系统控制台-System Console

.设置网站URL:

a.在System Console的GENERAL部分,点击Configuration.

b.在Site URL字段中,设置用户使用浏览器访问的URL.比如:https://mattermost.example.com.
如果你使用HTTPS,确保在Mattermost服务或者proxy服务设置了TLS

.设置邮件提醒
a.在System Console的NOTIFICATIONS部分,点击Email,然后执行下面几个步骤

设置 Enable Email Notification为 true

设置Notification Display Name为 No-Reply

设置Notification From Address为{域名},比如, kenmyzhang@outlook.com

设置SMTP Server Username为{SMTP-用户名},比如,kenmyzhang@outlook.com

设置SMTP Server Password为{SMTP-密码}

设置SMTP Server为{SMTP-服务器} 比如:smtp-mail.outlook.com
设置SMTP Server Port为465

设置Connection Security 为TLS或者STARTTLS
b.点击Test Connection.

c.连接成功后,点击Save

.设置文件和图片存储位置

提示:与消息相关的文件和图片并没有存储在数据库.他们存储在你所指定的路径.你可以存储在本地文件系统或者Amazon S3.

a.在System Console中的FILES部分,点击Storage

b.如果存储在本地,设置File Storage System为 Local File System,可以接受默认的Local Storage DIrectory或者输入指定路径.这个路径必须是存在的,并且Mattermost有写权限.可以是绝对路径或者相对路径.相对路径是相对于mattermost目录的.

c.如果存储在Amazon S3,设置File Storage System为Amazon S3并且输入你Amazon账号

d.点击Save保存

.重启Mattermost使配置生效

sudo systemctl restart mattermost

配置TLS
如果你想要使用HTTPS访问Mattermost,有两种选择

1.在Mattermost服务器上设置TLS

2.安装代理,例如NGINX,然后在代理上设置TLS

最简单的选择是在Mattermost服务器上设置TLS,但是,如果你想要支持200个以上的用户,使用proxy会有更好的性能和安全.代理服务器也提供了标准的HTTP请求日志.
在Mattermost服务器上配置TLS
.在System Consle > General > Configuration
a.设置Listem Address为:443
b.设置Connection Security为TLS
c. 设置Forward port 80 to 443为true
.激活CAP_NET_BIND_SERVICE能力,允许Mattermost绑定小数值端口.
cd /opt/mattermost/bin

sudo setcap cap_net_bind_service==+ep ./platform

.安装安全证书

你可以使用Let's Encrypt自动安装设置证书,或者指定你自己的证书
a.使用Let's Encrypt

设置User Let's Encrypt为true

重启Mattermost,使配置生效

b.使用自己的证书

设置User Let's Encrypt为false
设置TLS Certificate File 为证书文件的路径
设置TLS Key File为 私钥文件的路径
重启Mattermost使这些配置生效

在NGINX 代理上设置TLS

使用代理的好处:
SSL终端
HTTP到HTTPS重定向
端口映射 :80到:8065
标准请求日志
.安装NGINX
sudo apt-get install nginx
验证是否安装成功,可以执行下面命令

curl http://localhost
如果正常运行,会有下面打印显示

<!DOCTYPE html>
<html>
<head>
<title>Welcome to nginx!</title>.
.
.
<p><em>Thank you for using nginx.</em></p>
</body>
</html>
可以使用下面命令停止 启动 重启nginx
sudo service nginx stop
sudo service nginx start
sudo service nginx restart
接下来要做的是
将完全限定域名(FQDN),例如mattermost.example.com,映射到NGINX服务器
配置从互联网到Mattermost服务器的NGINX代理连接

.配置NGINX为代理
sudo touch /etc/nginx/sites-available/mattermost

.以root用户打开/etc/nginx/sites-available/mattermost,输入以下内容,并将里边的IP地址和完全限定域名FQDN你自己服务对应的值
upstream backend {
server 10.10.10.2:8065;
}

proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off;

server {
listen 80;
server_name    mattermost.example.com;

location ~ /api/v[0-9]+/(users/)?websocket$ {
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
client_max_body_size 50M;
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_buffers 256 16k;
proxy_buffer_size 16k;
proxy_read_timeout 600s;
proxy_pass http://backend; }

location / {
client_max_body_size 50M;
proxy_set_header Connection "";
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Frame-Options SAMEORIGIN;
proxy_buffers 256 16k;
proxy_buffer_size 16k;
proxy_read_timeout 600s;
proxy_cache mattermost_cache;
proxy_cache_revalidate on;
proxy_cache_min_uses 2;
proxy_cache_use_stale timeout;
proxy_cache_lock on;
proxy_pass http://backend; }
}
.删除已存在的默认sites-enabled文件

sudo rm /etc/nginx/sites-enabled/default

.启用mattermost配置
sudo ln -s /etc/nginx/sites-available/mattermost /etc/nginx/sites-enabled/mattermost
. 重启nginx使配置生效

sudo systemctl restart nginx

. 配置生效后,执行下面命令会看到Mattermost signup页面
curl http://localhost ,
.限制8065端口的访问权限
默认情况下,Mattermost服务器的8065端口接收来自网络上所有机器的连接.现使用防火墙拒绝所有机器连接8065端口,除了NGINX服务器以及管理Mattermost的服务器.如果你安装在Amazon Web Services,可以使用安全组来限制访问

. 配置SSL和HTTP/2

你可以使用你想要的任何证书,但在这里只展示如何从Let's Encrypt下载和安装证书,免费的证书授权

a.安装git

sudo apt-get install git

b.下载
git clone https://github.com/letsencrypt/letsencrypt c.切换目录
cd letsencryp
d.停止NGINX

sudo service nginx stop 或者 sudo systemctl stop nginx

e,确保没有监听80端口

netstat -na | grep ':80.*LISTEN'

f.安装letscrypt

./letsencrypt-auto certonly --standalone

提示时,输入你的域名.安装完成后,你可以在/etc/letsencrypt/live目录下找到证书

g.以root用户打开/etc/nginx/sites-available/mattermost,更新 下面加粗的几行,确保域名已经切换成proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mattermost_cache:10m max_size=3g inactive=120m use_temp_path=off;
server {
listen 80 default_server;
server_name {domain-name} ;
return 301 https://$server_name$request_uri; }

server {
listen 443 ssl http2;
server_name {domain-name} ;

ssl on;
ssl_certificate /etc/letsencrypt/live/{domain-name}/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/{domain-name}/privkey.pem;
ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers 'EECDH+AESGCM:EDH+AESGCM:AES256+EECDH:AES256+EDH';
ssl_prefer_server_ciphers on;
ssl_session_cache shared:SSL:10m;

location ~ /api/v[0-9]+/(users/)?websocket$ {
proxy_set_header Upgrade $http_upgrade;

h.重启NGINXsudo systemctl restart NGINXi.检查SSL证书是否安装正确 通过访问https://www.ssllabs.com/ssltest/index.html来测试SSL证书如果丢失链或证书路径有错误,则可能需要缺少中间证书。j .配置cron,每个月自动更新证书
crontab -e用你的域名替换掉{domain-name} @monthly /home/ubuntu/letsencrypt/letsencrypt-auto certonly --reinstall --nginx -d {domain-name} && sudo service nginx reload
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  Mattermost