0

I know how to set variables and use subroutines with the nginx builtin perl module INSIDE a "server" directive but, what I need to do is to set/rewrite the current domain before.

Let's say, we have a domain like

 admin.foobar.website.com

I want that a request to

 foobar.othersite.com

to point to the first address ( obviously website.com and othersite.com are hosted on the same webserver running nginx :) ).

For reasons I can't explain here, I can not use multiple server_name directive expressions, I have to do this before the server {} block, with perl or anyway possible.

1
  • What do you mean by "before the server {} block"? Before nginx has got a request?
    – VBart
    Sep 15, 2012 at 15:28

2 Answers 2

0

Please check out the solution that we have developed for this at http://www.logicwreck.com/index.php/2012/09/11/dynamic-vhosts-for-nginx-with-database-storage-of-domain-and-alias-info/

6
  • you just dinamically change the root ( and i already can accomplish this ), i need to change the domain itself so that nginx handle this transparently as if admin.foobar.website.com was directly requested. Sep 14, 2012 at 10:54
  • Actually this is being handled easily by this configuration, you will see the domain requested in the browser with the correct root, and if you access an alias of that domain you'll also the the alias name while the document root will be get from the db mapping. Sep 14, 2012 at 10:57
  • ok but i can't this by setting the root, i need to override the Host http header itself OUTSIDE a server directive ... can't explain why, we have a pretty complicated production environment :) Sep 14, 2012 at 10:58
  • Then this solution might not work for you Sep 14, 2012 at 11:00
  • unfortunately no, thanks anyway, +1 for the effort :) Sep 14, 2012 at 11:01
0
server {
    server_name admin.foobar.website.com;
    location / {
        proxy_pass foobar.othersite.com;
    }
}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .