2017-02-20 17 views
0

アプリケーションはaws(elasticbeanstack)のロードバランサの後ろにあります。ロードバランシングの前に、それはうまくいきました。アプリケーションは400 Bad Requestに応答します。このトピックについて多くの質問があります。私はたくさん試しました。スティッキセッション、アップストリームプロキシをhttp://localhostに変更、接続のアップグレード...しかし、私は把握できませんでした。ここでnginxのerror.logにある:Sails.jsソケット接続400 Bad Request

* 1217(接続)(111:接続 が拒否した)失敗した上流側に接続中のクライアント、:172.31.31.90、サーバー:、 リクエスト:「 /socket.ioをGET /?__sails_io_sdk_version=0.13.8 & __sails_io_sdk_platform =ブラウザ& __sails_io_sdk_language =ジャバスクリプト& EIO = 3 &輸送=ポーリング& T = LfS5yzc & SID = i1QLZeltxMS0D5oBAAAE HTTP/1.1" 、上流: "http://127.0.0.1:8081/socket.io/?__sails_io_sdk_version=0.13.8&__sails_io_sdk_platform=browser&__sails_io_sdk_language=javascript&EIO=3&transport=polling&t=LfS5yzc&sid=i1QLZeltxMS0D5oBAAAE"

Nginxの設定。

user nginx; 
worker_processes auto; 

error_log /var/log/nginx/error.log; 

pid  /var/run/nginx.pid; 

events { 
    use epoll; 
    worker_connections 1024; 
    multi_accept on; 
} 

http { 

    port_in_redirect off; 
    include  /etc/nginx/mime.types; 
    default_type application/octet-stream; 

    log_format main '$remote_addr - $remote_user [$time_local] "$request" ' 
         '$status $body_bytes_sent "$http_referer" ' 
         '"$http_user_agent" "$http_x_forwarded_for"'; 

    access_log /var/log/nginx/access.log main; 

    sendfile on; 
    tcp_nopush on; 
    tcp_nodelay on; 

    # Cache modifikasyonları 
    open_file_cache   max=10000 inactive=10m; 
    open_file_cache_valid 20m; 
    open_file_cache_min_uses 1; 
    open_file_cache_errors on; 

    # Transfers 
    client_body_buffer_size 10K;   # client POST buffer size 
    client_header_buffer_size 1k;   # client header size 
    client_max_body_size 20M;    # allowed size for a client request 
    large_client_header_buffers 2 1k;  # number and size of buffers for large client headers 

    # Timeouts 
    client_body_timeout 30; 
    client_header_timeout 30; 
    keepalive_timeout 65; 
    send_timeout 10; 

    # Elastic Beanstalk Modification(EB_INCLUDE) 

    log_format healthd '$msec"$uri"' 
         '$status"$request_time"$upstream_response_time"' 
         '$http_x_forwarded_for'; 

    include /etc/nginx/conf.d/*.conf; 

    # End Modification 
} 

サーバー:

upstream nodejs { 
    server 127.0.0.1:8081; 
    keepalive 256; 
} 

server { 
    listen 8080; 

    location/{ 
     proxy_pass http://nodejs; 
     #proxy_set_header Connection ""; 
     proxy_http_version 1.1; 
     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 Upgrade $http_upgrade; 
     proxy_set_header Connection "upgrade"; 

     proxy_buffers 8 24k; 
     proxy_buffer_size 2k; 
    } 

    gzip on; 
    gzip_comp_level 4; 
    gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript; 
} 

答えて

1

はelasticbeanstackのダッシュボードに移動して、あなたのアプリケーションのための環境をクリックしてください。

左側には垂直リストがあり、そのうち1つはConfiguration(構成)で、これをクリックする必要があります。下にスクロールして[ロードバランシング]ボックスを見つけ、そのボックスの右上隅にある編集ツールをクリックしてロードバランサを設定します。

このフォームでは、2番目のフィールドに「プロトコル」というラベルを付け、HTTP(選択する必要があります)とTCPの2つのオプションがあります。 TCPを選択し、下にスクロールして保存します。

ec2 AWS Admin> EC2> Security Groupsで、使用しているポート(8081)を開いてください。

最後に、.ebextensionsという名前のディレクトリをアプリケーションのルートに作成することです。この意志をそのすべてがうまくいかないと、あなたがなりたい自分を気にしない場合は

files: 
    "/etc/nginx/conf.d/websocketupgrade.conf" : 
     mode: "000755" 
     owner: root 
     group: root 
     content: | 
      proxy_set_header  Upgrade   $http_upgrade; 
      proxy_set_header  Connection  "upgrade"; 

、ちょうどnginxのを無効にし、ほとんどの時間:それに file.configをファイルを作成し、ファイルにこのコンテンツを追加(400)問題を解決する。

希望する

+0

私はしましたが動作しません。 – user305015

+0

また、TCPリスナーは、 "TCPプロトコルで利用できないスティッキー・オプション"という警告を出します。私は確信していませんが、ロードバランサの後にソケット接続が失われることを意味します。 – user305015

+0

投稿編集済み、上記をご覧ください。 – Sam

関連する問題