zodern / meteor-up

Production Quality Meteor Deployment to Anywhere
http://meteor-up.com/
MIT License
1.28k stars 279 forks source link

mup proxy : upstream prematurely closed connection while reading upstream #1286

Closed lc3t35 closed 2 years ago

lc3t35 commented 2 years ago

If I get an image (jpg) with the URL from a browser, the get works fine, image is displayed but when I try to save it, it fails. When I use <Image source={{uri: photo.url}} .../> in a react-native app, the image starts loading and stops loading after 5 seconds (so is not displayed) and Nginx proxy displays this error in the logs :

mup proxy logs -f --settings settings-production.json

[x.x.x.x];1mnginx.1    | api.xxxx.fr a.a.a.a - - [29/Dec/2021:23:54:41 +0000] "GET /cdn/storage/Images/xxxx/original/xxxx.jpg HTTP/2.0" 200 108240 "-" "Expo/2.23.2.101 CFNetwork/1237 Darwin/20.6.0"
[x.x.x.x];1mnginx.1    | ;1m2021/12/29 23:54:46 [error] 96#96: *7 upstream prematurely closed connection while reading upstream, client: a.a.a.a, server: api.xxxx.fr, request: "GET /cdn/storage/Images/xxxx/original/xxxx.jpg HTTP/2.0", upstream: "http://172.17.0.5:3000/cdn/storage/Images/xxxx/original/xxxx.jpg", host: "api.xxxx.fr"

Mup version (mup --version): 1.5.5

Mup config

{
  "servers": {
    "one": {
      "host": "1.2.3.4",
      "username": "root",
      "pem": "~/.ssh/pem"
    }
  },
  "mongo": {
    "oplog": true,
    "port": 27017,
    "version": "4.2.15",
    "servers": {
      "one": {}
    },
    "dbName": "api"
  },
  "proxy": {
    "domains": "subdomain.host.com",
    "clientUploadLimit": "150M",
    "nginxLocationConfig": "./nginxLocation.conf",
    "ssl": {
      "letsEncryptEmail": "email@domain.com"
    }
  },
  "app": {
    "name": "my-app",
    "path": "..",
    "volumes": {
      "/home/images": "/images"
    },
    "servers": {
      "one": {}
    },
    "buildOptions": {
      "serverOnly": true,
      "buildLocation": "/var/folders/....",
      "cleanBuildLocation": true
    },
    "env": {
      "ROOT_URL": "https://subdomain.host.com",
      "MONGO_URL": "mongodb://mongodb:27017/my-app",
      "MONGO_OPLOG_URL": "mongodb://mongodb/local",
      "NODE_ENV": "staging",
      "NODE_TLS_REJECT_UNAUTHORIZED": "0",
      "SOURCE_VERSION": "0.1.0",
      "MAIL_URL": "smtp://....",
      "VIRTUAL_HOST": "subdomain.host.com",
      "HTTPS_METHOD": "noredirect",
      "LETSENCRYPT_HOST": "subdomain.host.com",
      "LETSENCRYPT_EMAIL": "email@domain.com",
      "VIRTUAL_PORT": 3000,
      "HTTP_FORWARDED_COUNT": 1
    },
    "docker": {
      "image": "xxxx/meteord:1.9",
      "args": [
        "--link=mongodb:mongodb",
        "--link=mongodb:mongodb"
      ],
      "stopAppDuringPrepareBundle": true,
      "imagePort": 3000
    },
    "deployCheckWaitTime": 90,
    "enableUploadProgressBar": false,
    "type": "meteor"
  }
}

I've tested numerous nginxLocation.conf, here is the last one :

proxy_read_timeout 300s;
proxy_connect_timeout 75s;
proxy_send_timeout 300s;
proxy_request_buffering off;
proxy_buffering off;
proxy_redirect off;
proxy_socket_keepalive on;

I have another app that uses exactly the same configuration but no problem with images, any idea ?

I've tested it locally (without mup), I have the same behavior: the image is not downloaded in browser and not loaded in RN app => so this is not related to nginx/mup, investigating with https://github.com/veliovgroup/Meteor-Files/issues/829