Score:0

nginx map directive to redirect multiple domain name with variables

tn flag
Om-

I have multiple domains as below: www.domain1.com www.domain2.fr www.domain3.com www.domain4.fr www.domain5.biz

I wanted to redirect specific requests coming to the any domain let's say traffic coming to www.domain1.com with specific parameter should be proxy_pass to domain1.domainabc.com

upstream backend {
        server <server1 IP>:80;
        server <server2 IP>:80;
}

server {
        listen  80;
        server_name    www.domain1.com
        server_name    www.domain2.fr
        server_name    www.domain3.com
        server_name    www.domain4.fr
        server_name    www.domain5.biz 


    location / {
        common confs
        proxy_pass http://backend
                }                       

        location ~*/abc-xyz(.*) {
                proxy_pass https://$domain.domainabc.com/abc-xyz/$1;
                        }
                        
        
       location ~/images/(.*) {
                proxy_pass https://$domain.domainxyz.com/images/$1;
                    }
}   

where $domain can be domain1, domain2, domain3 etc based on request coming to respective domains...

your earliest help would be apricated.

I sit in a Tesla and translated this thread with Ai:

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.