# Use Node-RED as reverse proxy

**URL:** <https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017>\
**Category:** General\
**Created:** [7 July 2019 23:17 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017 "2019-07-07T23:17:04Z")\
**Posts on this page:** 17\
**Page:** 2

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [16 July 2019 21:54 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/21 "2019-07-16T21:54:29Z")

</div>

Hi Keni (@kenime),  
Thanks for your constructive feedback !!

> [@kenime](#):
>
> can we receieve the config from msg?

I have added this functionality on Github. You can find the explanation and example flow [here](https://github.com/bartbutenaers/node-red-contrib-http-proxy#url). I implemented it as standard Node-RED requires: the `msg.url` content is only be used when the URL is empty in the node's config screen ( **not** the other way around!).

> [@kenime](#):
>
> seems error event from http-proxy is not handled, not sure what would happen if there is error

I have extended this functionality on Github. You can find the explanation and example flow [here](https://github.com/bartbutenaers/node-red-contrib-http-proxy#error-handling).

> [@kenime](#):
>
> is it possible to return a msg instead of directly send the http response? Some people may want to post process the proxy result

Perhaps I could do this, but there is a issue when you look at the [modify response example](https://github.com/http-party/node-http-proxy#modify-response) of the http-proxy module that I use under the cover:

- _Finite response_: when receiving a standard resource response, the data chunks should be concatenated. As soon as the entire response has arrived, an output message could be send. Otherwise the next node would have an incomplete response. But this looks very much to a standard Node-RED solution http-in --\> http-request --\> http-out, so I'm not sure whether it has any use to implement it here again ...
- _Infinite (stream) response_: when receiving e.g. an Mjpeg stream, I cannot wait for the end of the response. So I would have to send an output message for every data chunk. But not sure what the next node could do with those individual data chunks?

> [@kenime](#):
>
> will the response header "polluted" by the proxy's response header? One of your use case is to hide internal resource link and you will definitely not hoping for exposing proxy headers to actual response header

That is indeed very true! But as explained above, this is my first experience with reverse proxies. So I don't know for sure if the response doesn't contain any references to the target server. Especially with all the available options ... _**If you (or anybody else with experience in this area) can test and verify this, please be my guest !!!!**_ All feedback or pull requests are welcome !

> [@krambriw](#):
>
> What I mean is maybe best explained with a typical use case example related to my own needs

Walter (@krambriw), will try to find some time this week to rewrite parts of the readme. Thanks for your tips!!

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [18 July 2019 19:49 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/22 "2019-07-18T19:49:26Z")

</div>

> [@kenime](#):
>
> will the response header "polluted" by the proxy's response header? One of your use case is to hide internal resource link and you will definitely not hoping for exposing proxy headers to actual response header

Hi Keni (@kenime ),  
I did some extra tests, and I have the impression that the [reverse proxy](https://www.npmjs.com/package/http-proxy) library (which I'm using behind the scenes) does something not correctly. Or I am not using it correctly somehow...

When I navigate in Chrome to my reverse-proxy node (which redirects me to [httpbin.org](http://httpbin.org)), then I see e.g. `server:nginx` in the response headers:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/443d9d57344f676a7aac14a1f433e4da6f5e09f8.png)

I did expect to see `server:Express`, since Node-RED (and also the reverse proxy node) is running ExpressJs. But now _Nginx is leaked, which is the webserver used to host [httpbin.org](http://httpbin.org)_ ;-(

Don't see what could be going wrong. Unless somebody else can give me the golden tip, I am going to rename my node to e.g. **node-red-contrib-http-redirect**. I have developed this node mainly for redirecting my mjpeg streams via Node-RED, and that seems to be working fine ...

**[EDIT]** I'm wondering now if I should have used [RedBird](https://github.com/OptimalBits/redbird), which seems to be a reverse proxy build on top of node-http-proxy. Not sure anymore ...

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [22 July 2019 07:55 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/23 "2019-07-22T07:55:40Z")

</div>

- Based on the above issue, I have renamed my node to node-red-contrib-http-proxy, and I have updated all above links to point to my [new readme](https://github.com/bartbutenaers/node-red-contrib-http-proxy/blob/master/README.md) page.
- I have added a CAUTION to the readme, to warn that some target server information 'might' leak to the client.
- @krambriw: I have totally rewritten the readme page. Hopefully it is a bit more clear now ...

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [22 July 2019 07:59 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/24 "2019-07-22T07:59:40Z")

</div>

So have you unpublished/deprecated the old version from npm? And removed the node-red tag from it so we won’t index it ?

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [22 July 2019 09:22 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/25 "2019-07-22T09:22:31Z")

</div>

Hey Dave, fortunately I hadn't published it on npm yet. For some reason, I had a feeling it wouldn't be correct from the first time...

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [22 July 2019 10:44 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/26 "2019-07-22T10:44:16Z")

</div>

Very nice indeed!!!  
I have a problem trying to install, I get "error 404 Not Found: node-red-contrib-http-proxy@latest"  
Is there an alternative way to install? Like starting with wget ....

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [22 July 2019 10:47 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/27 "2019-07-22T10:47:54Z")

</div>

try...

```auto
cd ~/.node-red (or wherever your node-red folder is)
npm install bartbutenaers/node-red-contrib-http-proxy

```

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [22 July 2019 10:52 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/28 "2019-07-22T10:52:22Z")

</div>

Indeed, will publish it on npm this evening...

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [22 July 2019 11:18 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/29 "2019-07-22T11:18:11Z")

</div>

Thank you, worked fine now!!!

---

<div class="post-metadata">

**Author:** ![krambriw](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/krambriw/32/5429_2.png) [@krambriw](https://discourse.nodered.org/u/krambriw)\
**Post date:** [22 July 2019 11:20 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/30 "2019-07-22T11:20:56Z")

</div>

Just one more question; Is this node independent of the format of the data or is it basically supporting all formats? I mean, there are so many various formats/protocols (for video as example, mp4, ts, mjpeg and many more)

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [22 July 2019 12:10 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/31 "2019-07-22T12:10:19Z")

</div>

I would expect it to be independent. It just passes **chunks of data** from the target to the client. For the proxy it are just a bunch of _bytes_ which he need to write to the response object...

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [22 July 2019 21:29 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/32 "2019-07-22T21:29:16Z")

</div>

> [@BartButenaers](#):
>
> Indeed, will publish it on npm this evening...

It is now published on NPM and available on [flows.nodered.org](http://flows.nodered.org):

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/4b4ab5b564e3af83216975c8fc1eee10930a64dc.png)

---

<div class="post-metadata">

**Author:** ![josekavunkal](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/josekavunkal/32/18505_2.png) [@josekavunkal](https://discourse.nodered.org/u/josekavunkal)\
**Post date:** [3 June 2020 17:56 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/33 "2020-06-03T17:56:47Z")

</div>

When I use this node ,it never hide my target URL .I can see the target url as browser URL .  
I was expecting it to hide it.

Even though it redirect the request the target is not getting hidden.  
Is this problem with my usage?

---

<div class="post-metadata">

**Author:** ![ristomatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ristomatti/32/5857_2.png) [@ristomatti](https://discourse.nodered.org/u/ristomatti)\
**Post date:** [3 June 2020 20:36 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/34 "2020-06-03T20:36:55Z")

</div>

There's a caution note about this in the documentation. I assume it's a side effect of the request/response simply being forwarded. Likely it's part of the headers sent by the proxied server.

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [3 June 2020 21:33 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/35 "2020-06-03T21:33:23Z")

</div>

> [@ristomatti](#):
>
> There's a caution note about this in the documentation

Thanks for your assistance!  
Indeed this node has been developed to solve a number of problems, but it is not a full blown http proxy:

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/57e840eda2ea7ac3582e7cf3f7f4511de9852cc2.png)

> [@josekavunkal](#):
>
> .I can see the target url as browser URL .

Can you explain that more in detail please, because with so less information I can only start guessing. Because in the browser you use an url referring to your Node-RED server, not to the target url?

---

<div class="post-metadata">

**Author:** ![josekavunkal](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/josekavunkal/32/18505_2.png) [@josekavunkal](https://discourse.nodered.org/u/josekavunkal)\
**Post date:** [4 June 2020 05:24 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/36 "2020-06-04T05:24:12Z")

</div>

Thank you for the response .If there a way to hide target URL?

---

<div class="post-metadata">

**Author:** ![BartButenaers](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bartbutenaers/32/10476_2.png) [@BartButenaers](https://discourse.nodered.org/u/BartButenaers)\
**Post date:** [4 June 2020 05:27 UTC](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017/37 "2020-06-04T05:27:24Z")

</div>

> [@BartButenaers](#):
>
> Can you explain that more in detail please, because with so less information I can only start guessing

Jose, can you please answer to my question and describe "_ **in detail** _" what you are doing...

[Previous page](https://discourse.nodered.org/t/use-node-red-as-reverse-proxy/13017.md?page=1)
