From f4d462b12b0034b716f7ed09a983deee01cf68bc Mon Sep 17 00:00:00 2001 From: ahmedre Date: Sat, 19 Nov 2016 05:26:14 -0500 Subject: [PATCH] Fix node-http-proxy host in proxy request node-http-proxy was putting a host header with the current server name, which was thus causing nginx on the receiving end to send the request to the default handler (or the first one). This patch asks node-http-proxy to rewrite the host and port, and also to change the origin of the host header to onequran's url. --- src/server/config/express.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/server/config/express.js b/src/server/config/express.js index 5c46e9d19..2e416e52f 100644 --- a/src/server/config/express.js +++ b/src/server/config/express.js @@ -20,7 +20,9 @@ const proxyApi = httpProxy.createProxyServer({ const proxyOneQuran = httpProxy.createProxyServer({ target: process.env.ONE_QURAN_URL, secure: false, - proxyTimeout: 15000 + proxyTimeout: 15000, + autoRewrite: true, + changeOrigin: true }); proxyApi.on('error', (error, req, res) => {