How to exclude specific subdomains server_name in nginx configuration -


i'm using wildcard in server_name. want redirect subdomains of example.com (configured *.example.com) foo.com except xyz.example.com

i have configuration follows

server {         listen          80;         server_name     *.example.com;         location / {             proxy_pass      http://$1.foo.com;         } } 

i don't want change request coming xyz.example.com

you need @ least 2 server blocks, , nginx select more specific server block handle request. see this document details.

you need server block xyz.example.com such as:

server {     listen      80;     server_name xyz.example.com;      location / {         proxy_pass http://$1.foo.com;     } } 

then either default_server or wild card server, such as:

server {     listen 80;     server_name *.example.com;     return http://foo.com/; } 

or:

server {     listen 80 default_server;     return http://foo.com/; } 

Comments

Popular posts from this blog

php - Wordpress website dashboard page or post editor content is not showing but front end data is showing properly -

How to get the ip address of VM and use it to configure SSH connection dynamically in Ansible -

javascript - Get parameter of GET request -