Rocket.Chat服务器安装+Nginx反向代理+SSL配置

安装 Rocket.Chat

sudo apt update && sudo apt upgrade

安装 snap

Ubuntu 18.04

sudo apt install snap -y

Ubuntu 14.04

sudo apt-get install snapd -y

通过 snap 安装 Rocket.chat

sudo snap install rocketchat-server

安装 Nginx

sudo apt install -y nginx
sudo systemctl start nginx
sudo systemctl enable nginx

创建 Nginx 配置文件

sudo nano /etc/nginx/sites-available/rocketchat.conf

填入以下内容(假设你的域名是example.com):

server {
    listen 80;

    server_name example.com;

    location / {
        proxy_pass http://localhost:3000/;
        proxy_set_header Host $http_host;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }
}

创建软连接

sudo ln -s /etc/nginx/sites-available/rocketchat.conf /etc/nginx/sites-enabled/

重新加载 Nginx

sudo nginx -s reload

配置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

安装成功

浏览器访问 https://example.com

服务器禁ping

禁止ping,避免服务器被扫描发现:

sysctl -w net.ipv4.icmp_echo_ignore_all=1

如要恢复ping,改为0即可:

sysctl -w net.ipv4.icmp_echo_ignore_all=0

rocketchat-ui.png

发表新评论