Distinguish different virtual hosts by domain name

Keywords: Nginx Windows DNS vim

1.1.1. What is a domain name

A domain name is a website.

www.baidu.com

www.taobao.com

www.jd.com

Tcp/ip

Dns Server: Resolve the domain name to an IP address.Save the mapping relationship between the domain name and ip.

First-level domain name:

Baidu.com

Taobao.com

Jd.com

Secondary domain name:

www.baidu.com

Image.baidu.com

Item.baidu.com

Tertiary domain name:

1.Image.baidu.com

Aaa.image.baidu.com

DNS server is dedicated to domain name resolution


image.png

A domain name corresponds to an ip address, and an ip address can be bound by multiple domain names.

Local tests can modify hosts files.
Modify window s hosts file: (C:\Windows\System32\drivers\etc)
You can configure the mapping relationship between domain name and ip. If the corresponding relationship between domain name and IP is configured in the hosts file, you do not need to go to the dns server.



# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#   127.0.0.1       localhost
#   ::1             localhost

#0.0.0.0 statsfe2.update.microsoft.com.akadns.net
#0.0.0.0 fe2.update.microsoft.com.akadns.net
#0.0.0.0 s0.2mdn.net
#0.0.0.0 survey.watson.microsoft.com
#0.0.0.0 view.atdmt.com
#0.0.0.0 watson.microsoft.com
#0.0.0.0 watson.ppe.telemetry.microsoft.com
#0.0.0.0 vortex.data.microsoft.com
#0.0.0.0 vortex-win.data.microsoft.com
#0.0.0.0 telecommand.telemetry.microsoft.com
#0.0.0.0 telecommand.telemetry.microsoft.com.nsatc.net
#0.0.0.0 oca.telemetry.microsoft.com
#0.0.0.0 sqm.telemetry.microsoft.com
#0.0.0.0 sqm.telemetry.microsoft.com.nsatc.net
#0.0.0.0 watson.telemetry.microsoft.com
#0.0.0.0 watson.telemetry.microsoft.com.nsatc.net
#0.0.0.0 redir.metaservices.microsoft.com
#0.0.0.0 choice.microsoft.com
#0.0.0.0 choice.microsoft.com.nsatc.net
#0.0.0.0 wes.df.telemetry.microsoft.com
#0.0.0.0 services.wes.df.telemetry.microsoft.com
#0.0.0.0 sqm.df.telemetry.microsoft.com
#0.0.0.0 telemetry.microsoft.com
#0.0.0.0 telemetry.appex.bing.net
#0.0.0.0 telemetry.urs.microsoft.com
#0.0.0.0 settings-sandbox.data.microsoft.com
#0.0.0.0 watson.live.com
#0.0.0.0 statsfe2.ws.microsoft.com
#0.0.0.0 corpext.msitadfs.glbdns2.microsoft.com
#0.0.0.0 compatexchange.cloudapp.net
#0.0.0.0 a-0001.a-msedge.net
#0.0.0.0 sls.update.microsoft.com.akadns.net
#0.0.0.0 diagnostics.support.microsoft.com
#0.0.0.0 corp.sts.microsoft.com
#0.0.0.0 statsfe1.ws.microsoft.com
#0.0.0.0 feedback.windows.com
#0.0.0.0 feedback.microsoft-hohm.com
#0.0.0.0 feedback.search.microsoft.com
#0.0.0.0 rad.msn.com
#0.0.0.0 preview.msn.com
#0.0.0.0 ad.doubleclick.net
#0.0.0.0 ads.msn.com
#0.0.0.0 ads1.msads.net
#0.0.0.0 ads1.msn.com
#0.0.0.0 a.ads1.msn.com
#0.0.0.0 a.ads2.msn.com
#0.0.0.0 adnexus.net
#0.0.0.0 adnxs.com
#0.0.0.0 az361816.vo.msecnd.net
#0.0.0.0 az512334.vo.msecnd.net
#0.0.0.0 ssw.live.com
#0.0.0.0 ca.telemetry.microsoft.com
#0.0.0.0 i1.services.social.microsoft.com
#0.0.0.0 i1.services.social.microsoft.com.nsatc.net
#0.0.0.0 df.telemetry.microsoft.com
#0.0.0.0 reports.wes.df.telemetry.microsoft.com
#0.0.0.0 cs1.wpc.v0cdn.net
#0.0.0.0 vortex-sandbox.data.microsoft.com
#0.0.0.0 oca.telemetry.microsoft.com.nsatc.net
#0.0.0.0 pre.footprintpredict.com
#0.0.0.0 spynet2.microsoft.com
#0.0.0.0 spynetalt.microsoft.com
#0.0.0.0 fe3.delivery.dsp.mp.microsoft.com.nsatc.net
#0.0.0.0 cache.datamart.windows.com
#0.0.0.0 db3wns2011111.wns.windows.com
#0.0.0.0 settings-win.data.microsoft.com
#0.0.0.0 v10.vortex-win.data.microsoft.com
#0.0.0.0 win10.ipv6.microsoft.com
#0.0.0.0 ca.telemetry.microsoft.com
#0.0.0.0 i1.services.social.microsoft.com.nsatc.net

#127.0.0.1 wa.kuwo.cn
#127.0.0.1 atm.youku.com
#127.0.0.1 vid.atm.youku.com
#127.0.0.1 Fvid.atm.youku.com
#127.0.0.1 walp.atm.youku.com
#127.0.0.1 html.atm.youku.com
#127.0.0.1 valb.atm.youku.com
#127.0.0.1 valf.atm.youku.com
#127.0.0.1 valo.atm.youku.com
#127.0.0.1 valp.atm.youku.com
#127.0.0.1 lstat.youku.com
#127.0.0.1 speed.lstat.youku.com
#127.0.0.1 urchin.lstat.youku.com
#127.0.0.1 stat.youku.com
#127.0.0.1 static.lstat.youku.com
#127.0.0.1 valc.atm.youku.com

#tudou
#127.0.0.1 adextensioncontrol.tudou.com
#127.0.0.1 iwstat.tudou.com
#127.0.0.1 nstat.tudou.com
#127.0.0.1 stats.tudou.com
#127.0.0.1 *.p2v.tudou.com*
#127.0.0.1 at-img1.tdimg.com
#127.0.0.1 at-img2.tdimg.com
#127.0.0.1 at-img3.tdimg.com
#127.0.0.1 adplay.tudou.com
#127.0.0.1 adcontrol.tudou.com
#127.0.0.1 stat.tudou.com
#127.0.0.1 walp.atm.youku.com
#ku6
#127.0.0.1 1.allyes.com.cn
#127.0.0.1 analytics.ku6.com
#127.0.0.1 gug.ku6cdn.com
#127.0.0.1 ku6.allyes.com
#127.0.0.1 ku6afp.allyes.com
#127.0.0.1 pq.stat.ku6.com
#127.0.0.1 st.vq.ku6.cn
#127.0.0.1 stat0.888.ku6.com
#127.0.0.1 stat1.888.ku6.com
#127.0.0.1 stat2.888.ku6.com
#127.0.0.1 stat3.888.ku6.com
#127.0.0.1 static.ku6.com
#127.0.0.1 v0.stat.ku6.com
#127.0.0.1 v1.stat.ku6.com
#127.0.0.1 v2.stat.ku6.com
#127.0.0.1 v3.stat.ku6.com
#qiyi
#127.0.0.1 afp.qiyi.com
#127.0.0.1 focusbaiduafp.allyes.com
#sina
#127.0.0.1 dcads.sina.com.cn
#pptv
#127.0.0.1 wafp.pptv.com
#127.0.0.1 jp.as.pptv.com
#127.0.0.1 de.as.pptv.com
#127.0.0.1 as.aplus.pptv.com
#127.0.0.1 static.g.pptv.com
#127.0.0.1 vas.aplus.pptv.com
#127.0.0.1 tips.passport.pptv.com
#127.0.0.1 static.qipao.pptv.com
#127.0.0.1 atm.youku.com
#127.0.0.1 vid.atm.youku.com
#127.0.0.1 Fvid.atm.youku.com
#127.0.0.1 walp.atm.youku.com
#127.0.0.1 html.atm.youku.com
#127.0.0.1 valb.atm.youku.com
#127.0.0.1 valf.atm.youku.com
#127.0.0.1 valo.atm.youku.com
#127.0.0.1 valp.atm.youku.com
#127.0.0.1 lstat.youku.com
#127.0.0.1 speed.lstat.youku.com
#127.0.0.1 urchin.lstat.youku.com
#127.0.0.1 stat.youku.com
#127.0.0.1 static.lstat.youku.com
#127.0.0.1 valc.atm.youku.com
#127.0.0.1 atm.youku.com
#127.0.0.1 vid.atm.youku.com
#127.0.0.1 Fvid.atm.youku.com
#127.0.0.1 walp.atm.youku.com
#127.0.0.1 html.atm.youku.com
#127.0.0.1 valb.atm.youku.com
#127.0.0.1 valf.atm.youku.com
#127.0.0.1 valo.atm.youku.com
#127.0.0.1 valp.atm.youku.com
#127.0.0.1 lstat.youku.com
#127.0.0.1 speed.lstat.youku.com
#127.0.0.1 urchin.lstat.youku.com
#127.0.0.1 stat.youku.com
#127.0.0.1 static.lstat.youku.com
#127.0.0.1 valc.atm.youku.com
#127.0.0.1 atm.youku.com
#127.0.0.1 vid.atm.youku.com
#127.0.0.1 Fvid.atm.youku.com
#127.0.0.1 walp.atm.youku.com
#127.0.0.1 html.atm.youku.com
#127.0.0.1 valb.atm.youku.com
#127.0.0.1 valf.atm.youku.com
#127.0.0.1 valo.atm.youku.com
#127.0.0.1 valp.atm.youku.com
#127.0.0.1 lstat.youku.com
#127.0.0.1 speed.lstat.youku.com
#127.0.0.1 urchin.lstat.youku.com
#127.0.0.1 stat.youku.com
#127.0.0.1 static.lstat.youku.com
#127.0.0.1 valc.atm.youku.com
#127.0.0.1 atm.youku.com
#127.0.0.1 vid.atm.youku.com
#127.0.0.1 Fvid.atm.youku.com
#127.0.0.1 walp.atm.youku.com
#127.0.0.1 html.atm.youku.com
#127.0.0.1 valb.atm.youku.com
#127.0.0.1 valf.atm.youku.com
#127.0.0.1 valo.atm.youku.com
#127.0.0.1 valp.atm.youku.com
#127.0.0.1 lstat.youku.com
#127.0.0.1 speed.lstat.youku.com
#127.0.0.1 urchin.lstat.youku.com
#127.0.0.1 stat.youku.com
#127.0.0.1 static.lstat.youku.com
#127.0.0.1 valc.atm.youku.com
#127.0.0.1 atm.youku.com
#127.0.0.1 vid.atm.youku.com
#127.0.0.1 Fvid.atm.youku.com
#127.0.0.1 walp.atm.youku.com
#127.0.0.1 html.atm.youku.com
#127.0.0.1 valb.atm.youku.com
#127.0.0.1 valf.atm.youku.com
#127.0.0.1 valo.atm.youku.com
#127.0.0.1 valp.atm.youku.com
#127.0.0.1 lstat.youku.com
#127.0.0.1 speed.lstat.youku.com
#127.0.0.1 urchin.lstat.youku.com
#127.0.0.1 stat.youku.com
#127.0.0.1 static.lstat.youku.com
#127.0.0.1 valc.atm.youku.com
#127.0.0.1 l.qq.com
#127.0.0.1 ra.gtimg.com
#127.0.0.1 livec.l.qq.com
#127.0.0.1 atm.youku.com
#127.0.0.1 vid.atm.youku.com
#127.0.0.1 Fvid.atm.youku.com
#127.0.0.1 walp.atm.youku.com
#127.0.0.1 html.atm.youku.com
#127.0.0.1 valb.atm.youku.com
#127.0.0.1 valf.atm.youku.com
#127.0.0.1 valo.atm.youku.com
#127.0.0.1 valp.atm.youku.com
#127.0.0.1 lstat.youku.com
#127.0.0.1 speed.lstat.youku.com
#127.0.0.1 urchin.lstat.youku.com
#127.0.0.1 stat.youku.com
#127.0.0.1 static.lstat.youku.com
#127.0.0.1 valc.atm.youku.com
#127.0.0.1 atm.youku.com
#127.0.0.1 vid.atm.youku.com
#127.0.0.1 Fvid.atm.youku.com
#127.0.0.1 walp.atm.youku.com
#127.0.0.1 html.atm.youku.com
#127.0.0.1 valb.atm.youku.com
#127.0.0.1 valf.atm.youku.com
#127.0.0.1 valo.atm.youku.com
#127.0.0.1 valp.atm.youku.com
#127.0.0.1 lstat.youku.com
#127.0.0.1 speed.lstat.youku.com
#127.0.0.1 urchin.lstat.youku.com
#127.0.0.1 stat.youku.com
#127.0.0.1 static.lstat.youku.com
#127.0.0.1 valc.atm.youku.com
#127.0.0.1 atm.youku.com
#127.0.0.1 vid.atm.youku.com
#127.0.0.1 Fvid.atm.youku.com
#127.0.0.1 walp.atm.youku.com
#127.0.0.1 html.atm.youku.com
#127.0.0.1 valb.atm.youku.com
#127.0.0.1 valf.atm.youku.com
#127.0.0.1 valo.atm.youku.com
#127.0.0.1 valp.atm.youku.com
#127.0.0.1 lstat.youku.com
#127.0.0.1 speed.lstat.youku.com
#127.0.0.1 urchin.lstat.youku.com
#127.0.0.1 stat.youku.com
#127.0.0.1 static.lstat.youku.com
#127.0.0.1 valc.atm.youku.com
#127.0.0.1 atm.youku.com
#127.0.0.1 vid.atm.youku.com
#127.0.0.1 Fvid.atm.youku.com
#127.0.0.1 walp.atm.youku.com
#127.0.0.1 html.atm.youku.com
#127.0.0.1 valb.atm.youku.com
#127.0.0.1 valf.atm.youku.com
#127.0.0.1 valo.atm.youku.com
#127.0.0.1 valp.atm.youku.com
#127.0.0.1 lstat.youku.com
#127.0.0.1 speed.lstat.youku.com
#127.0.0.1 urchin.lstat.youku.com
#127.0.0.1 stat.youku.com
#127.0.0.1 static.lstat.youku.com
#127.0.0.1 valc.atm.youku.com

#-------′?′|?á±?ìú??êó?μ1???-------

There is also a useful tool, SwitchHosts!.exe

image.png

Local IP-bound domain name settings


image.png

Create a new camel

image.png

After binding the relationship between ip and domain name

Next we'll finish on the virtual host
cd /usr/local/nginx

Found -rw-r--r--. 1 root 2656 July 28 01:39 nginx.conf
Add server configures the same port, but server_name is the bound domain name

    server {
        listen       80;
        server_name  wwww.camel.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html-test1;
            index  index.html index.htm;
        }
}
    server {
        listen       80;
        server_name  wwww.camel1.com;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html-test;
            index  index.html index.htm;
        }
}

Step 1 cd/usr/local/nginx/copy html

[root@Nigux nginx]# cp -r html html-test
[root@Nigux nginx]# cp -r html html-test1

Differentiate between two different interfaces


drwxr-xr-x. 2 root root 4096 7 February 2923:06 conf
drwxr-xr-x. 2 root root   40 7 28/01:39 html
drwxr-xr-x. 2 root root   40 7 29/22:54 html81
drwxr-xr-x. 2 root root   40 7 Month 30 00:09 html-test
drwxr-xr-x. 2 root root   40 7 Month 30 00:09 html-test1
drwxr-xr-x. 2 root root   19 7 28/01:39 sbin
[root@Nigux nginx]# vim html-test/index.html
[root@Nigux nginx]# vim html-test1/index.html

After modifying the page, after shift+zz save exits, restart the service

[root@Nigux nginx]# sbin/nginx -s reload

Test:

http://192.168.191.129:81/

image.png

http://192.168.191.129/

image.png

Posted by netxfly on Tue, 30 Jul 2019 09:13:06 -0700