nginx - two subdomain configuration

后端 未结 5 977
耶瑟儿~
耶瑟儿~ 2020-12-23 13:17

I\'m new to Nginx and I\'m trying to get subdomains working.

What I would like to do is take my domain (let\'s call it example.com) and add:

    <
5条回答
  •  甜味超标
    2020-12-23 13:52

    1. Add A field for each in DNS provider with sub1.example.com and sub2.example.com

    2. Set the servers. Keep example.com at last

    As below

    server {
        server_name sub1.example.com;
        # sub1 config
    }
    server {
        server_name sub2.example.com;
        # sub2 config
    }
    server {
        server_name example.com;
        # the rest of the config
    }
    
    1. Restart Nginx sudo systemdctrl restart nginx

提交回复
热议问题