best approach to run http proxy between two vhosts

#1
So I am migrating a system that uses a portal that derives its code base from the home application, but it needs to push the URL through the index.php for processing.

I've tried setting static context but that is looking for a physical location - what I need to do is pass the extra location data so that the main engine can process it.

However, I also need to passthrough a resource directory as a static context (there is a physical location.

I have two vhosts set up that point to the same docroot.

Main software is in bihelp.example.com

Portal vhost is biportal.example.com but I need to push the /(.*) to bihelp.example.com/portal/biportal/

In other words, biportal.example.com/* needs to map to bihelp.example.com/portal/biportal/*

However, biportal.example.com/resource/* needs to map to bihelp.example.com/resource/* - the resource folder needs to be, essentially, excluded from the extra mapping.

In Nginx it looks like this:

Code:
  # Resource proxy
  location ~* ^/resource/ {
    rewrite ^/resource/(.*) /resource/$1 break;
    proxy_pass https://bihelp.example.com;
  }

  # Everything else
  location / {
    rewrite ^/(.*) /portal/biportal/$1 break;
    proxy_pass https://bihelp.example.com;
    proxy_set_header DevblocksProxySSL 1;
    proxy_set_header DevblocksProxyHost biportal.example.com;
    proxy_set_header DevblocksProxyBase "";
  }
The headers are used by the software - they aren't as important. I guess I don't know if I should use rewrites, try to set a static context, or set up an external app - what is the most streamlined way to do this?
 
#3
I was able to get this to work but is there any method that preserves the host being called?

When I visit biwork.example.org it does rewrite/map to beihelp.example.org/portal/link/ - but it changes the URL as well - it doesn't stay as biwork.example.org
 
Top