1

My requirement is to redirect the URL, which is running on port 80 with reverse proxy. I guess I would have to use URL redirection, reverse proxy together.

There is already a web-domain active like : https://abcd.cdsw.intranet.example.com However, we would want to use reverse proxy to hid the diversions from the URL, but this URL runs with port 80 I guess.

As a result, I couldn't able to start httpd server in Redhat enterprise Linux 7 to introduce reverse proxy. Can someone help me with this?

Expected:

Actual URL : https://abcd.cdsw.intranet.example.com/login

Expected URL : http or https://example.com/cdsw

  • Do you have control over the web-app? Can you change the code to make it redirect somewhere else, or are you going to need to configure the proxy to intercept and change the redirects? – Stephen Ostermiller Dec 8 '17 at 12:56
  • But, I am not sure whether Cloudera Datascience Workbench uses any sort of web-app like that. – Vijay Dec 8 '17 at 13:54
  • I am looking for the latter one as I don't know which webapp that CDSW application uses. @StephenOstermiller – Vijay Dec 8 '17 at 15:12
  • What are you using for your reverse proxy? Apache? Nginx? Something else? We can't help you configure it unless we know what it is. – Stephen Ostermiller Dec 8 '17 at 15:14
  • I am gonna use Apache not nginx, wanna use separate virtual host block file for this under /etc/httpd/conf.d/cdsw.conf @StephenOstermiller – Vijay Dec 8 '17 at 20:20
2

Under Apache, using the ProxyPassReverse directive will do what you want. It will take the redirect from the backend server and replace the backend host name with the front end name. From the documentation:

This directive lets Apache httpd adjust the URL in the Location, Content-Location and URI headers on HTTP redirect responses. This is essential when Apache httpd is used as a reverse proxy (or gateway) to avoid bypassing the reverse proxy because of HTTP redirects on the backend servers which stay behind the reverse proxy.

They also have an example of how it is typically used in conjunction with adjusting cookie paths:

ProxyPass         "/mirror/foo/" "http://backend.example.com/"
ProxyPassReverse  "/mirror/foo/" "http://backend.example.com/"
ProxyPassReverseCookieDomain  "backend.example.com"  "public.example.com"
ProxyPassReverseCookiePath  "/"  "/mirror/foo/"

You may find that there are also absolute links in the HTML documents from the backend server. If that is the case, you can use the mod_proxy_html module to also replace those.


It sounds like that in this case you didn't develop the backend webapp yourself and it may not have settings for running behind a proxy server. However, if you can modify the code on the backend webapp, you can modify it to write its links and redirects using the front end host name.

The front end proxy server passes the host name to the backend using the X-Forwarded-For header. You can change your server to use the value from this header rather than ServerName so that it works seamlessly behind a proxy.

  • So, if I go by your suggestion, my configuration would be like, ProxyPass "/login" "https://abcd.cdsw.intranet.example.com" ProxyPassReverse "/login" "https://abcd.cdsw.intranet.example.com" ProxyPassReverseCookieDomain "abcd.cdsw.intranet.example.com" "example.com/cdsw" ProxyPassReverseCookiePath "/" "/login" We can assume the above configuration works, but port 443, and 80 is already being used by CDSW application. How can I use this redirection without stopping the application? @Stephen Ostermiller – Vijay Dec 11 '17 at 11:57
  • ..cont even if I stop it, httpd can be started, but the application may barf saying the port 443, 80 is already being used by httpd isn't it? – Vijay Dec 11 '17 at 11:57
  • To use reverse proxy you either need two different servers, or use different ports. One solution is to run the CDSW application on a different machine. Another solution is to run the CDSW application on ports 8080 and 8443. That allows you to reverse proxy them from a virtual host on the main ports along with other virtual hosts. – Stephen Ostermiller Dec 11 '17 at 12:15
  • That's more likely even I was telling to my colleague to the same, but still trying if there are any alternatives. We are approaching the vendor to see if they can help. From the Webapp side they can help on that I believe. Thanks for the suggestions. – Vijay Dec 11 '17 at 15:30
  • I have tried something of this sort based on the suggestion provided on a different host where CDSW application is not installed cont... @Stephen – Vijay Dec 16 '17 at 17:11

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.