Skip to content
This repository has been archived by the owner on Mar 14, 2024. It is now read-only.

Latest commit

 

History

History
175 lines (153 loc) · 4.22 KB

1.部署文档.md

File metadata and controls

175 lines (153 loc) · 4.22 KB

部署文档

启动http服务

cp .env.example .env
go run main.go 或者 air

启动tcp服务(该功能目前只是个玩具 无实际作用)

go run main.go --serve tcp-serve  //启动tcp服务端
go run main.go --serve tcp-client //启动tcp客户端

启动后输入账号密码登录

使用到的图床

https://sm.ms/register

功能测试

1.使用微博登录,测试账号: admin 123456

nginx配置实例

  upstream websocket {
		server 127.0.0.1:9502;
	}
server
{
    listen 80;
	 listen 443 ssl http2;
    server_name im.pltrue.top;
    index index.php index.html index.htm default.php default.htm default.html;
    set $root_path '';

    if ($server_port !~ 443){
        rewrite ^(/.*)$ https://$host$1 permanent;
    }
    ssl_certificate    /www/server/panel/vhost/cert/core.pltrue.top/fullchain.pem;
    ssl_certificate_key    /www/server/panel/vhost/cert/core.pltrue.top/privkey.pem;
    ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3;
    ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
    ssl_prefer_server_ciphers on;
    ssl_session_cache shared:SSL:10m;
    ssl_session_timeout 10m;
    error_page 497  https://$host$request_uri;

    //访问前端
    if ( $request_uri !~* /api ) {
        set $root_path /www/wwwroot/core.pltrue.top/dist;
    }
   //访问语音文件
     if ( $request_uri ~* /voice ) {
        set $root_path /www/wwwroot/go-core;
    }
  #location /core {
  #  proxy_pass http://127.0.0.1:9502;
   # proxy_http_version 1.1;
  #  proxy_set_header Upgrade $http_upgrade;
  #  proxy_set_header Connection "upgrade";
  #}
   //访问ws
  location /core {
             proxy_pass http://127.0.0.1:9502;
             proxy_read_timeout 60s;
             proxy_set_header Host $host;
             proxy_set_header X-Real_IP $remote_addr;
             proxy_set_header X-Forwarded-for $remote_addr;
             proxy_http_version 1.1;
             proxy_set_header Upgrade $http_upgrade;
             proxy_set_header Connection 'Upgrade';
  }
   //访问接口
   location /api {
    proxy_pass http://127.0.0.1:9502;
    proxy_http_version 1.1;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection "upgrade";
   }
    root $root_path;
    #REWRITE-START URL重写规则引用,修改后将导致面板设置的伪静态规则失效
    include /www/server/panel/vhost/rewrite/admin.pltrue.top.conf;
      #REWRITE-END
    location / {
            try_files $uri $uri/ /index.html;
      }
    #禁止访问的文件或目录
    location ~ ^/(\.user.ini|\.htaccess|\.git|\.svn|\.project|LICENSE|README.md)
    {
        return 404;
    }
    
    #一键申请SSL证书验证目录相关设置
    location ~ \.well-known{
        allow all;
    }
  
    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf|wav)$
    {
        expires      30d;
        error_log off;
        access_log /dev/null;
    }
    
    location ~ .*\.(js|css)?$
    {
        expires      12h;
        error_log off;
        access_log /dev/null; 
    }

    access_log  /www/wwwlogs/core.pltrue.top.zaplog;
    error_log  /www/wwwlogs/core.pltrue.top.error.zaplog;
}

.env文件配置说明

APP_NAME=GoIM
APP_ENV=production
APP_YM=https://im.pltrue.top //域名
APP_NODE=127.0.0.1 //当前服务节点 请使用集群能访问的ip
APP_CLUSTER_MODEL=false //开启集群模式
APP_GO_COROUTINES=100000 //协程池数量
HTTP_PORT=9502 //http端口
TCP_PORT=8000  //tcp端口
GRPC_PORT=8002 //grpc通讯端口
SWAGGER_PORT=9502 //接口文档端口
LOG_ADDRESS=././logs/

//mysql库
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=im
DB_USERNAME=root
DB_PASSWORD=root
DB_LOC=Asia/Shanghai

//redis服务
REDIS_HOST=127.0.0.1
REDIS_PORT=6379
REDIS_PASSWORD=
REDIS_DB=0

//rabbitmq配置
RABBITMQ_HOST=127.0.0.1
RABBITMQ_PORT=5672
RABBITMQ_USER=guest
RABBITMQ_PASSWORD=guest

//微博登录配置
WEIBO_CLIENT_ID=
WEIBO_CLIENT_SECRET=
WEIBO_REDIRECT_URI=http://im.pltrue.top/login

GITHUB_CLIENT_ID=
GITHUB_CALLBACK=http://127.0.0.1:9502/api/giteeCallBack
GITHUB_SECRET=

//jwt
JWT_SIGN_KEY=IJjkKLMNO567PQX12R-
JWT_EXPIRATION_TIME=685200
BASE64_ENCRYPT=

GITEE_API_KEY=

//图片服务
SM_NAME=latent
SM_PASSWORD=
SM_TOKEN=