zoukankan      html  css  js  c++  java
  • Swarm之Websocket链接慢解决

    因为需要前台websocket 链接需要在warm中寻找后台在哪个机子中部署,所以链接很慢。使用nginx代码的方式解决。

    user  nginx;
    worker_processes  auto;
    
    error_log  /var/log/nginx/error.log info;
    pid        /var/run/nginx.pid;
    
    
    events {
        worker_connections  4096;
    }
    
    
    http {
            include       /etc/nginx/mime.types;
            default_type  application/octet-stream;
    
            log_format  main  '[$time_local]|$request_time|$remote_addr|"$request"|$status|$body_bytes_sent|"$http_referer"|"$http_host"|"$proxy_add_x_forwarded_for"|"$host"|"$http_user_agent"';
    
            access_log  /var/log/nginx/access.log  main;
    
            sendfile        on;
        #tcp_nopush     on;
    
        keepalive_timeout  65;
    
        map $http_upgrade $connection_upgrade {
              default upgrade;
              ''   close;
        }
    
        server {
            listen 80;
            server_name  localhost;
            client_max_body_size 0;
            #
            add_header Access-Control-Allow-Origin *;
            add_header Access-Control-Allow-Headers 'DNT,X-Mx-ReqToken,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Authorization';
            proxy_connect_timeout   60;
            proxy_read_timeout      60;
            proxy_send_timeout      60;    
            proxy_next_upstream error timeout invalid_header;
            
            location / {
                root   /usr/share/nginx/html;
                index  index.html index.htm;
            }
                    
            location /platform/websocket/rtdata {
                proxy_pass http://platform-manager-svc:8720/rtdata;
                proxy_http_version 1.1;
                proxy_set_header Upgrade $http_upgrade;
                proxy_set_header Connection $connection_upgrade;
            }
    
            #error_page  404              /404.html;
    
            # redirect server error pages to the static page /50x.html
            #
            error_page   500 502 503 504  /50x.html;
            location = /50x.html {
                root   /usr/share/nginx/html;
            }
    
            # proxy the PHP scripts to Apache listening on 127.0.0.1:80
            #
            #location ~ .php$ {
            #    proxy_pass   http://127.0.0.1;
            #}
    
            # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
            #
            #location ~ .php$ {
            #    root           html;
            #    fastcgi_pass   127.0.0.1:9000;
            #    fastcgi_index  index.php;
            #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
            #    include        fastcgi_params;
            #}
    
            # deny access to .htaccess files, if Apache's document root
            # concurs with nginx's one
            #
            #location ~ /.ht {
            #    deny  all;
            #}
        }
    }
  • 相关阅读:
    元素单侧阴影效果
    有关动画的总结
    吸底效果
    使用seajs来引入js代码
    引用POPUI来实现弹窗效果,且弹窗中的内容可以点击事件
    Js文本溢出自动添加省略号ellipsis
    line-hieght与vertical-align的区别与联系
    实现文本框中输入限制字数的效果
    下拉菜单的实现
    基本SQL命令 (1.SQL命令使用规则/2.库管理/3.表管理/4.表记录管理/5.更改库,库的默认字符集/6.连接数据库的过程/7.数据类型)
  • 原文地址:https://www.cnblogs.com/wuwei928/p/13844990.html
Copyright © 2011-2022 走看看