Afternoon gentlemen,

My current setup is one single site, lets call that http://production.com, that's being served by Nginx on port 80 as a static cache and Apache in the background on port 8080 localhost, nothing fancy really and this works very well.

What I'm trying to do now is to make the URL http://production.com/foobar to include data from an external URL which we'll call http://internal.com/.

The issue I'm having is that if I browse to http://internal.com/ I get automatically redirected to http://www.internal.com/forum/forum.php due to this being a vBulletin forum that have their own internal redirects and what not based on the Site URL variable. Of course the same thing happens if I try to proxy it through Nginx, I just get "forwarded" to the ../forum/forum.php URL.

So, how would I go about to solve this? Is there a way to make that redirect invisible somehow and not let Nginx actually follow it in the address bar somehow? Basically an iframe without using an actual iframe. :-)

This is my Nginx code snippet I'm trying with now:

    location /foobar {
            proxy_pass      http://internal.com/;
            proxy_redirect  off;
            proxy_set_header        Host $host;

Ideas? Thanks in advance.

  • 2
    I do understand the problem and there are complex solutions like ngx.lua module than allows parsing of returned proxy contnent but it is easy to drown there. You can just pass /forum requests to internal.com/forum and my preferred way is to make separate subdomain for this forum like forum.production.com – Andrei Mikhaltsov Mar 12 '13 at 14:05
  • Hi Andrei, yeah if I would be allowed to put it on a sub domain I would've done that immediately, unfortunately I don't have that choice. I do have another idea which, if it works, I'll make sure to post here as well. Thanks – Lars Mar 12 '13 at 14:21
  • Have you tried with proxy_redirect default? This is supposed to handle HTTP redirects from the upstream. If you're referring to HTML links in the content that's a different story however. – mgorven Mar 12 '13 at 18:30

I've figured out that in this case you basically have two different options.

  1. You either use the ngx.lua module, as Andrei Mikhaltsov pointed out, and change the proxy on whatever HTTP response you'll get back, this might of course be quite the nightmare.

  2. You do some changes on whatever application you're "forwarding" to, which in our case was a forum.

In our case, we chose number 2 and basically put them under the same domain and did some changes to the forum.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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