VoceChat是一款由国人开发的聊天平台,轻量(15M左右),可在自己的服务器(或本地)搭建,跨平台客户端。如果有需要的小伙伴可以安装运行测试一下,官方提供了两种安装模式Shell+Docker。如果想快速体验可以选择Docker+Nginx的方式(如下文)
VoceChat安装方法:Docker+Nginx模式
以下内容摘自官网文档:https://vocechat-doc.vercel.app/zh-cn/install/install-by-docker
① 在Docker下运行Vocechat(以域名chat.vmvps.com为例)
docker run -d --restart=always \ -p 3009:3000 \ --name vocechat-server \ -v ~/.vocechat-server/data:/home/vocechat-server/data \ privoce/vocechat-server:latest \ --network.frontend_url "https://chat.vmvps.com"
② 修改Nginx配置
Nginx配置文件目录一般在/etc/nginx/conf.d,新建 Nginx 配置文件chat.vmvps.com.conf,并配置好相应http请求:
server{ server_name chat.vmvps.com; location / { proxy_pass http://127.0.0.1:3009; # 此处端口号取决于docker运行的对外端口号 proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_max_temp_file_size 0; # 关掉硬盘缓存,增加写速度 # SSE 相关配置 proxy_http_version 1.1; proxy_set_header Connection ''; } }
③ 运行Vocechat初始化配置
nginx -t #测试Nginx配置是否正确 nginx -s reload #重载Nginx配置
浏览器访问http://chat.vmvps.com(注意提前解析好域名DNS到你的服务器)进入初始化页面,即为配置成功。
④ 设置安全证书,实现HTTPS(以Cetrbot为例)
1. 安装Certbot(官网:https://certbot.eff.org/instructions选择相应版本下载)
2. 运行Certbot自动读取配置Nginx
sudo certbot certonly --nginx
Nginx配置将变为
server{ server_name chat.vmvps.com; location / { proxy_pass http://127.0.0.1:3009; # 此处端口号取决于docker运行的对外端口号 proxy_redirect off; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504; proxy_max_temp_file_size 0; # 关掉硬盘缓存,增加写速度 # SSE 相关配置 proxy_http_version 1.1; proxy_set_header Connection ''; } listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/chat.vmvps.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/chat.vmvps.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot } server{ if ($host = chat.vmvps.com) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; server_name chat.vmvps.com; return 404; # managed by Certbot }
重载Nginx配置
nginx -s reload
浏览器访问http://chat.vmvps.com将自动切换为https协议