Using map directive for multiple virtual hosts
Francis Daly
francis at daoine.org
Mon Oct 2 23:40:01 UTC 2017
On Tue, Oct 03, 2017 at 05:28:28AM +1000, Nikolai Lusan wrote:
Hi there,
> I have a requirement to rewrite incoming URL requests for multiple
> virtual hosts, each with a unique (possibly overlapping) set of incoming
> requests. We have each vhost in a server block, but since the map directive
> lives in the http block I think that the behaviour we are currently seeing
> is a result of having multiple map declarations not working - currently the
> first virtual host with a configured map is working as expected, subsequent
> maps are just returning the default.
What request do you make?
What response do you get?
What response do you want instead?
> So the configuration looks something like this (these are abbreviated
> examples with all the php processing stuff pulled out of it)
I think you may have abbreviated these a bit too much. You never try to
use $new_uri_site1 or $new_uri_site2.
> /etc/nginx/our-sites/site1.com:
> map $request_uri $new_uri_site1 {
> /store/product1 /store/new_products;
> /contact/us /contact/about;
> /services/consulting /contact/consulting;
> }
> Apart from moving the map directives inside each relevant server block as
> rewrite rules does anyone know of a working solution for this situation?
http://nginx.org/r/map
map does not go inside server{}.
Can you give a specific example of a response from nginx that is not
what you want?
f
--
Francis Daly francis at daoine.org
More information about the nginx
mailing list