Quantcast
Channel: Nginx Forum - How to...
Viewing all articles
Browse latest Browse all 4759

Regexp in proxy pass map for subdomain

$
0
0
Hi, working with nginx reverse proxy and I'm trying to achieve mapping for proxy pass for subdomains.

My code is this:

http {

map $server_name $backend {
mail.(.*) mail_backend_http;
default default_backend_http;
}

upstream default_backend_http {
server 192.168.10.1:80;
}

upstream mail_backend_http {
server 192.168.253.1:80;
}

server {
listen 80;
listen [::]:80;

server_name *.*;

location / {
proxy_pass http://$backend;
}
}
}


I'm trying to do the following:
client connected to the http://foo.foo or http://foo.bar gets passed to the default_backend_http and client connected to the http://mail.foo.foo or http://mail.foo.bar gets connected to the mail_backend_http.

How to achieve this? mail.(.*) is not working, mail.* or mail.(.*).(.*) nonetheless.

Viewing all articles
Browse latest Browse all 4759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>