如何自定义在AWS弹性魔豆nginx的以LOADBALANCE流星? [英] How do I customize nginx on AWS elastic beanstalk to loadbalance Meteor?

查看:283
本文介绍了如何自定义在AWS弹性魔豆nginx的以LOADBALANCE流星?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在AWS弹性魔豆运行流星。一切都和不同之处在于它没有运行的WebSockets与下面的​​错误运行:

I am running Meteor on AWS Elastic Beanstalk. Everything is up and running except that it's not running Websockets with the following error:

WebSocket connection to 'ws://MYDOMAIN/sockjs/834/sxx0k7vn/websocket' failed: Error during WebSocket     handshake: Unexpected response code: 400 

我unstanding是添加类似:

My unstanding was to add something like:

 proxy_set_header升级$ http_upgrade;  proxy_set_header连接升级;

proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade";

要代理配置,通过我的YML配置文件。

To the proxy config, via my YML config file.

通过我的.exbextension配置文件:

Via my .exbextension config file:

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

我已经通过SSH连接到服务器,我可以看到它与这两条线的proxy.conf。

I have ssh'd into the server and I can see the proxy.conf with those two lines in it.

当我打我的web服务器我仍然看到期间的WebSocket握手错误:错误。

When I hit my webserver I still see the "Error during WebSocket handshake: " error.

我已经配置了棍子会议和下面的端口我的魔豆负载:

I have my beanstalk load configured with stick sessions and the following ports:

顺便说一句我也看到<一href="https://meteorhacks.com/load-balancing-your-meteor-app.html">https://meteorhacks.com/load-balancing-your-meteor-app.html我想:

BTW I did see https://meteorhacks.com/load-balancing-your-meteor-app.html and I tried to:

启用HTTP负载粘性会话端口80上的平衡 启用TCP负载均衡端口8080,它允许的WebSocket 但也似乎无法得到的工作要么。

Enable HTTP load balancing with Sticky Session on Port 80 Enable TCP load balancing on Port 8080, which allows websocket But could not seem to get that working either.

添加另一射击在一些YAML,这并不在这里工作:<一href="https://gist.github.com/adamgins/0c0258d6e1b8203fd051">https://gist.github.com/adamgins/0c0258d6e1b8203fd051

Adding another shot at some YAML that does NOT work here": https://gist.github.com/adamgins/0c0258d6e1b8203fd051

任何帮助AP preciated?

Any help appreciated?

推荐答案

通过帮助来自AWS付费支持了很多,我得到了这个工作。现实的情况是我不远处则下跌到一定SED syntaxt。

With a LOT of help from AWS paid support, I got this working. The reality is I was not far off it was down to some SED syntaxt.

下面是当前工作(要点):

option_settings:

  - option_name: AWS_SECRET_KEY
    value: <SOMESECRET>

  - option_name: AWS_ACCESS_KEY_ID
    value: <SOMEKEY>

  - option_name: PORT
    value: 8081

  - option_name: ROOT_URL
    value: <SOMEURL>

  - option_name: MONGO_URL
    value: <SOMEMONGOURL>

    - option_name: MONGO_OPLOG_URL
    value: <SOMEMONGOURL>

  - namespace: aws:elasticbeanstalk:container:nodejs
    option_name: ProxyServer
    value: nginx

    option_name: GzipCompression
    value: true

  - namespace: aws:elasticbeanstalk:container:nodejs:staticfiles

    option_name: /public
    value: /public

    container_commands:

  01_nginx_static:
    command: |
      sed -i '/\s*proxy_set_header\s*Connection/c \
              proxy_set_header Upgrade $http_upgrade;\
              proxy_set_header Connection "upgrade";\
        ' /tmp/deployment/config/#etc#nginx#conf.d#00_elastic_beanstalk_proxy.conf

在除了这一点,你需要钻进你的负载均衡,并从HTTP更改监听器以TCP:

In addition to this you need to got into your Load balancer and change the Listener from HTTP to TCP:

描述如下:http://docs.aws.amazon.com/elasticbeanstalk/latest/dg/using-features.managing.elb.html).

这篇关于如何自定义在AWS弹性魔豆nginx的以LOADBALANCE流星?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆