先更新一下系统
sudo apt update && sudo apt upgrade
安装snap
apt install -y snapd snapcraft
.
.
省略Nginx配置步骤
- 安装 Rocket.Chat
sudo snap install rocketchat-server
- 安装后,Rocket.Chat 服务会自动启动,检查一下是否在运行:
sudo service snap.rocketchat-server.rocketchat-server status
- 创建反向代理配置
sudo vim /etc/nginx/sites-available/rocketchat.conf
# Upstreams
upstream backend {
server 127.0.0.1:3000;
}
server {
server_name chat.feihongph.com;
location / {
# proxy_pass http://localhost:3000/;
proxy_pass http://backend/;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
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 https;
proxy_set_header X-Nginx-Proxy true;
proxy_redirect off;
}
}
-
通过以下方式创建指向它的链接来启用新配置
/etc/nginx/sites-available/
:
sudo ln -s /etc/nginx/sites-available/rocketchat.conf /etc/nginx/sites-enabled/
-
配置SSL证书
sudo apt-get install -y software-properties-common
sudo add-apt-repository ppa:certbot/certbot
sudo apt-get update
sudo apt-get install -y python-certbot-nginx
sudo certbot --nginx // 设置证书相关信息
sudo certbot renew --dry-run // 自动续约
- 放行服务器的
443
和3000
端口