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.
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.