Web连接在EC2 Meteor部署上被拒绝

问题描述

我正在使用MUP将流星应用程序部署到运行Ubuntu 18的EC2实例。我的部署似乎可以正常工作,但是当我尝试在浏览器中访问实例的公共URL时,出现“连接被拒绝。” 我要为此疯狂!

我认为这将是一个AWS问题,例如端口未打开,但是我的EC2入站规则似乎应该起作用:

enter image description here

我通过SSH进入实例以查看是否一切正常,我认为是正常的。对于初学者来说,docker容器似乎运行良好:

CONTAINER ID        IMAGE                    COMMAND                  CREATED             STATUS              PORTS                NAMES
2b70717ce5c9        mup-oil-pricing:latest   "/bin/sh -c 'exec $M…"   About an hour ago   Up About an hour    0.0.0.0:80->80/tcp   oil-pricing

虽然仍然使用SSH,但是当我按下curl localhost:80时,我在控制台中恢复了HTML,这表明该应用程序(Meteor应用程序)运行良好。

我检查了Ubuntu防火墙是否处于活动状态,但我认为不是:

ubuntu@ip-172-30-1-118:~$ sudo ufw status verbose
Status: inactive

我的端口似乎也很好(据我所知):

ubuntu@ip-172-30-1-118:~$ sudo netstat -tulpn | grep LISTEN
tcp        0      0 10.0.3.1:53             0.0.0.0:*               LISTEN      3230/dnsmasq
tcp        0      0 127.0.0.53:53           0.0.0.0:*               LISTEN      344/systemd-resolve
tcp        0      0 0.0.0.0:22              0.0.0.0:*               LISTEN      7903/sshd: /usr/sbi
tcp6       0      0 :::22                   :::*                    LISTEN      7903/sshd: /usr/sbi
tcp6       0      0 :::80                   :::*                    LISTEN      13597/docker-proxy

但是,当我在本地计算机上转到Chrome并尝试通过我分配的弹性IP(34.231.39.181或EC2地址(https://ec2-34-231-39-181.compute-1.amazonaws.com/)使用EC2实例访问该站点时,我得到了:

This site can’t be reached
ec2-34-231-39-181.compute-1.amazonaws.com refused to connect.

我不认为这是MUP的问题,但这是MUP配置,以防万一:

module.exports = {
  servers: {
    one: {
      host: '34.231.39.181',username: 'ubuntu',pem: [[MY PEM FILE]]
    }
  },hooks: {
    'pre.deploy': {
      remoteCommand: 'docker system prune -a --force' // PRUNE DOCKER IMAGES
    },},app: {
    name: 'oil-pricing',path: '../',servers: {
      one: {},buildOptions: {
      serverOnly: true,env: {
      ROOT_URL: 'https://ec2-34-231-39-181.compute-1.amazonaws.com/',MONGO_URL: [[MY MONGO URL]]
      PORT: 80,docker: {
      image: 'abernix/meteord:node-8.15.1-base',// per: https://github.com/zodern/meteor-up/issues/692
    },enableuploadProgressBar: true
  },};

当我运行mup deploy时,所有内容都会检出:

Started TaskList: Pushing Meteor App
[34.231.39.181] - Pushing Meteor App Bundle to the Server
[34.231.39.181] - Pushing Meteor App Bundle to the Server: SUCCESS
[34.231.39.181] - Prepare Bundle
[34.231.39.181] - Prepare Bundle: SUCCESS

Started TaskList: Configuring App
[34.231.39.181] - Pushing the Startup Script
[34.231.39.181] - Pushing the Startup Script: SUCCESS
[34.231.39.181] - Sending Environment Variables
[34.231.39.181] - Sending Environment Variables: SUCCESS

Started TaskList: Start Meteor
[34.231.39.181] - Start Meteor
[34.231.39.181] - Start Meteor: SUCCESS
[34.231.39.181] - Verifying Deployment
[34.231.39.181] - Verifying Deployment: SUCCESS

如果这很重要,我正在使用流星1.8.1。

任何帮助将不胜感激!

解决方法

您的sudo netstat -tulpn | grep LISTEN显示您正在侦听端口80。但是您在以下位置使用HTTPS:

https://ec2-34-231-39-181.compute-1.amazonaws.com

这将连接到没有监听的端口443。因此,要么更改您的应用程序以侦听端口443上的HTTPS连接(将需要正确的ssl证书),要么使用将转到端口80的HTTP(未加密):

http://ec2-34-231-39-181.compute-1.amazonaws.com