Welcome! Log In Create A New Profile

Advanced

Regexp in proxy pass map for subdomain

Posted by Get Schwifty 
Regexp in proxy pass map for subdomain
May 22, 2019 05:36PM
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.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 307
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready