From 7b8f88fcd72ae2e75e0750f1c00da1e2e82bd850 Mon Sep 17 00:00:00 2001 From: euklid Date: Mon, 7 Mar 2016 17:18:46 -0800 Subject: [PATCH] allow usage of express' 'trust proxy' to use reverse proxy for parse server, increased minimum required express version --- README.md | 3 ++- docker-compose.yml | 3 ++- index.js | 5 +++++ package.json | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 7cdee40..1a8be06 100644 --- a/README.md +++ b/README.md @@ -268,7 +268,8 @@ parse-server: ALLOW_CLIENT_CLASS_CREATION: $ALLOW_CLIENT_CLASS_CREATION # true APP_NAME: $APP_NAME PUBLIC_SERVER_URL: $PUBLIC_SERVER_URL -# ... + TRUST_PROXY: $TRUST_PROXY # false +# ... ``` Remote parse-cloud-code image: diff --git a/docker-compose.yml b/docker-compose.yml index 8d76e39..52d07a2 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -34,7 +34,8 @@ parse-server: ALLOW_CLIENT_CLASS_CREATION: $ALLOW_CLIENT_CLASS_CREATION # true APP_NAME: $APP_NAME PUBLIC_SERVER_URL: $PUBLIC_SERVER_URL - links: + TRUST_PROXY: $TRUST_PROXY + links: - mongo volumes_from: - parse-cloud-code diff --git a/index.js b/index.js index d8765eb..78db997 100755 --- a/index.js +++ b/index.js @@ -90,6 +90,11 @@ var api = new ParseServer({ var app = express(); +if(process.env.TRUST_PROXY == 1) { + console.log("trusting proxy"); + app.enable('trust proxy'); +} + // Serve the Parse API on the /parse URL prefix var mountPath = process.env.PARSE_MOUNT || '/parse'; app.use(mountPath, api); diff --git a/package.json b/package.json index a0e84d1..37334fd 100644 --- a/package.json +++ b/package.json @@ -11,7 +11,7 @@ "dependencies": { "nodemon": "^1.8.1", "docker-links": "^1.0.2", - "express": "~4.2.x", + "express": "~4.13.x", "kerberos": "~0.0.x", "parse": "~1.6.12", "parse-server": "~2.1.4"