Search code examples
node.jsapachehttp-redirectproxypass

Detect if user uses proxypass in Apache or NodeJS


I have developed a NodeJS app running on port 1234. In order not to have ":1234" in the address bar, I use proxypass/proxypassreverse so that the URLs look like "mysite.com/myapp/".

Everything works fine but my app is behind a SSO. When a user tries to reach "mysite.com/myapp", he's redirected to the SSO, he logs in, then the SSO redirects him to "mysite.com:1234" (because the SSO doesn't understand that there is a proxypass).

I created a javascript on my page detecting if there is ":1234" in the URL and if so, the window.location replaces ":1234" by "/myapp".

This is not a very good solution for me, I think there may be a NodeJS or even better an Apache solution to detect if the URL reached is the ":1234" one or the "/myapp" one.

Thanks in advance.


Solution

  • OK my problem was that NodeJS sent to the SSO the URL with the port number. All I needed to do was to replace the port number by the string I use for the ProxyPass:

    req.get('host').replace(':' + PORT, '/node')