nginx配置文件:
upstream cat { server 192.168.149.133:9502 weight=5; server 192.168.149.134:9502 weight=5; } server { listen 80; #listen [::]:80; server_name www.test1.com; index index.html index.htm index.php default.html default.htm default.php; root /home/wwwroot/www.test1.com/public; include other.conf; #error_page 404 /404.html; # Deny access to PHP files in specific directory #location ~ /(wp-content|uploads|wp-includes|images)/.*.php$ { deny all; } #include enable-php.conf; include enable-php-pathinfo.conf; #这一句支持pathinfor; location / { if (!-e $request_filename) { rewrite ^(.*)$ /index.php?s=$1 last; break; } } location /swoole/ { proxy_pass http://cat; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header X-real-ip $remote_addr; proxy_set_header X-Forwarded-For $remote_addr; } location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ { expires 30d; }
只要是/swoole/路径中访问的连接 都会转发到负载均衡服务器
聊天室前端:
两台服务器都打开9502端口,即可,但现在还有一个问题,每台服务器都会生成各自的fd 发送消息时会有问题,这个问题还未解决,解决后在更新