Welcome! Log In Create A New Profile

Advanced

Reverse proxy with a subdirectory to a server at top level

Posted by jeffreyg 
Reverse proxy with a subdirectory to a server at top level
January 07, 2011 01:37PM
I've been working with NGINX for a little while now but am having trouble solving a particular issue.

I have a set of machines that each run a third-party reporting server. This third-party system puts its web server at the top level of the domain. I can hit it by going to https://reportserver_ip/ only. I can change the port but can not put it in a subdirectory.

I want to use NGINX to reverse proxy to these servers. My goal is to have one domain hit the correct reporting servers based on a subdirectory. Example:

https://mypublicdomain/report1
https://mypublicdomain/report2
https://mypublicdomain/report3

Each would end up reverse proxying to its respective report server.

However, this third-party report server has a number of links that are non-relative.
For example an img with src="\images\..." or a link to javascript at href="\javascripts\..."
Since those links don't have the respective "report1" or "report2" in the url, NGINX doesn't know where to send them.

I can get this working if I reverse proxy to the report servers using different subdomains (report1.mypublicdomain) or different ports (mypublicdomain:XX1) but for different reasons I really need them to all be on the same domain and port.

Is there a way to do this? Can I set it up somehow so that even though the report servers have those non-relative links they will end up proxying to the right place?

If I had control over the third-party reporting tool, I'd just add a base tag to the html head and it would work, but I don't have the ability to do that.

Thanks for help or ideas anyone can provide.
Jeff
Re: Reverse proxy with a subdirectory to a server at top level
January 07, 2011 05:00PM
Well, we've been working on this and thought we had come up with a solution.

The idea was to use HttpSubsModule and HttpSubModule.
(http://wiki.nginx.org/HttpSubsModule and http://wiki.nginx.org/HttpSubModule)

I figured I could use HttpSubModule to add a <base> tag to the <head> element which specified the url and subdirectory AND to use HttpSubsModule to get rid of all instances of leading forward slashes in references.

Unfortunately, the third-party report servers use compressed http using gz. And from the forums it looks like HttpSub and HttpSubs don't work with gzipped responses. I haven't seen any workarounds for this online.

So, is there a different way to solve the initial issue? Or, alternatively, is there a way to use the HttpSubsModule with a compressed http response?

Thanks again for any help,
Jeff
Re: Reverse proxy with a subdirectory to a server at top level
January 22, 2011 11:59AM
It looks like I can force the server to turn off gzip encoding by setting:

proxy_set_header Accept-Encoding "";

When I set up the proxy pass.
Re: Reverse proxy with a subdirectory to a server at top level
August 10, 2015 12:04PM
I tried adding proxy_set_header Accept-Encoding ""; and it doesn't work, with google at least :/
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 140
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready