因为公司只有一台服务器,配置足够,很多服务部署在一起,所以不得不开nginx,80端口就占用冲突,所以操作让nginx转发im-server和app-server,按照文档检验,都是通过的,但app连不上im-server。 im-server的nginx完整贴片,stream和http块属于nginx主配置文件, server块是宝塔反向代理站点的nginx子配置文件。
stream { log_format tcp_format '$time_local|$remote_addr|$protocol|$status|$bytes_sent|$bytes_received|$session_time|$upstream_addr|$upstream_bytes_sent|$upstream_bytes_received|$upstream_connect_time'; access_log /www/wwwlogs/tcp-access.log tcp_format; error_log /www/wwwlogs/tcp-error.log; include /www/server/panel/vhost/nginx/tcp/*.conf; # 野火IM配置需要NG做4层代理1883 upstream im_tcp_server { server 127.0.0.1:1884; } server { listen 1883 so_keepalive=600s; proxy_pass im_tcp_server; tcp_nodelay on; } # 野火IM配置需要NG做4层代理1883 } http{ …… upstream imserver { server 127.0.0.1:9090; } …… } proxy_cache_path /www/wwwroot/im.xxx.com/proxy_cache_dir levels=1:2 keys_zone=im_xxx_com_cache:20m inactive=1d max_size=5g; server { listen 80; listen 443 ssl http2 ; listen [::]:80; server_name im.xxx.com; index index.php index.html index.htm default.php default.htm default.html; root /www/wwwroot/im.xxx.com; #CERT-APPLY-CHECK--START # 用于SSL证书申请时的文件验证相关配置 -- 请勿删除 include /www/server/panel/vhost/nginx/well-known/im.xxx.com.conf; #CERT-APPLY-CHECK--END #SSL-START SSL相关配置,请勿删除或修改下一行带注释的404规则 #error_page 404/404.html; ssl_certificate /www/server/panel/vhost/cert/im.xxx.com/fullchain.pem; ssl_certificate_key /www/server/panel/vhost/cert/im.xxx.com/privkey.pem; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; ssl_ciphers EECDH+CHACHA20:EECDH+CHACHA20-draft:EECDH+AES128:RSA+AES128:EECDH+AES256:RSA+AES256:EECDH+3DES:RSA+3DES:!MD5; ssl_prefer_server_ciphers on; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; add_header Strict-Transport-Security "max-age=31536000"; error_page 497 https://$host$request_uri; #SSL-END #REDIRECT START #REDIRECT END #ERROR-PAGE-START 错误页配置,可以注释、删除或修改 #error_page 404 /404.html; #error_page 502 /502.html; #ERROR-PAGE-END #PHP-INFO-START PHP引用配置,可以注释或修改 include enable-php-00.conf; #PHP-INFO-END #IP-RESTRICT-START 限制访问ip的配置,IP黑白名单 #IP-RESTRICT-END #BASICAUTH START #BASICAUTH END #SUB_FILTER START #SUB_FILTER END #GZIP START #GZIP END #GLOBAL-CACHE START #GLOBAL-CACHE END #WEBSOCKET-SUPPORT START proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection $connection_upgrade; #WEBSOCKET-SUPPORT END #PROXY-CONF-END #SERVER-BLOCK START location /route { 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_pass http://imserver; } #社区版需要启用下面一段,专业版不能用 location /im { 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_pass http://imserver; } location /api { proxy_pass http://imserver; } location /fs { proxy_pass http://imserver; } location /robot { 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_pass http://imserver; } location /channel { 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_pass http://imserver; } #SERVER-BLOCK END #禁止访问的文件或目录 location ~ ^/(\.user.ini|\.htaccess|\.git|\.env|\.svn|\.project|LICENSE|README.md) { return 404; } #一键申请SSL证书验证目录相关设置 location /.well-known{ allow all; } #禁止在证书验证目录放入敏感文件 if ( $uri ~ "^/\.well-known/.*\.(php|jsp|py|js|css|lua|ts|go|zip|tar\.gz|rar|7z|sql|bak)$" ) { return 403; } #LOG START access_log /www/wwwlogs/im.xxx.com.log; error_log /www/wwwlogs/im.xxx.com.error.log; #LOG END }
app-server是可以通的,uni-chat的demo两个地址改成我自己的,登录时可以的 登录时的app-0.67.jar 部分日志 app-server的宝塔反代站点nginx配置。 application.properties中server.port=9088
server { listen 80; server_name im-app.xxx.com; rewrite ^(.*)$ https://im-app.xxx.com permanent; } server { listen 443 ssl; server_name im-app.xxx.com; root /www/wwwroot/im-app.xxx.com; index index.html index.htm; client_max_body_size 30m; ssl_certificate /www/server/panel/vhost/cert/im-app.xxx.com/fullchain.pem; ssl_certificate_key /www/server/panel/vhost/cert/im-app.xxx.com/privkey.pem; ssl_session_timeout 5m; ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4; ssl_protocols TLSv1.1 TLSv1.2 TLSv1.3; ssl_prefer_server_ciphers on; location / { proxy_read_timeout 100s; proxy_pass http://127.0.0.1:9088; 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_set_header X-Forwarded-Proto $scheme; } # 可选的路径分流 # location /app/ { # proxy_pass http://127.0.0.1:9088/; # } access_log /www/wwwlogs/im-app.xxx.com.log; error_log /www/wwwlogs/im-app.xxx.com.error.log; }
数据库都是连的按照文档调教过的Mysql8.0.33,同源不同库。 最后uni-chat的demo登录成功后,会话列表连接失败,我的页面空白。 真机测试控制台没看到啥有效信息。
1883端口是开的,通过nginx stream块做tcp转发到wildfirechat.conf中port=1884
HeavyRain IM服务和NG是部署在同一台服务器的吗?如果是的话,可以在NG中去掉1883/1884端口的配置,客户端会直接连接到IM服务的1883端口
tenk 是在一台服务器,1883转发到1884的tcp四层代理的处理是看了您在这个帖子的回复https://bbs.wildfirechat.cn/thread-1700.htm。 去掉之后还是app连接失 ...
HeavyRain 去掉NG中的映射后,IM服务直接暴露tcp的端口到外面,确认这个端口有没有放开防火墙
HeavyRain 可以用域名,但不支持HTTPS,如果单位不允许用HTTPS,可以考虑用我们专业版IM服务,专业版IM服务支持TCP的短链接,请参考 https://docs.wildfirechat.cn/blogs ...