How to exclude specific subdomains server_name in nginx configuration

旧时模样 提交于 2019-11-29 04:04:45

You need at least two server blocks, and nginx will select the more specific server block to handle the request. See this document for details.

You will need a server block for xyz.example.com such as:

server {
    listen      80;
    server_name xyz.example.com;

    location / {
        proxy_pass http://$1.foo.com;
    }
}

Then either a default_server or a 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/;
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!