成人在线亚洲_国产日韩视频一区二区三区_久久久国产精品_99国内精品久久久久久久

您的位置:首頁(yè)技術(shù)文章
文章詳情頁(yè)

apache虛擬主機(jī)

瀏覽:140日期:2024-07-01 13:36:52

問(wèn)題描述

最近在研究虛擬主機(jī),然后我配置了兩個(gè)虛擬主機(jī),如下apache虛擬主機(jī)

其中一個(gè)的ServerName設(shè)置為127.0.0.1 。然后再C盤(pán)的hosts文件里面增加apache虛擬主機(jī)

那么問(wèn)題來(lái)了。我在瀏覽器直接輸入www.abc.com時(shí)候會(huì)訪(fǎng)問(wèn)到E:/wamp/crm這個(gè)項(xiàng)目,為什么呢?在hosts里面www.abc.com不是對(duì)應(yīng)127.0.0.1嗎,不是應(yīng)該訪(fǎng)問(wèn)E:/wamp/wamp/www這個(gè)項(xiàng)目嗎?然后我在瀏覽器直接輸入127.0.0.1的時(shí)候訪(fǎng)問(wèn)的是E:/wamp/wamp/www這個(gè)項(xiàng)目?就是這里搞不懂。。。。請(qǐng)大神搭救搭救。。。。。。

問(wèn)題解答

回答1:

官方文檔在此:An In-Depth Discussion of Virtual Host Matching

你這個(gè)屬于“Name-based vhost”,就看這一段好了:

If there are multiple VirtualHost directives listing the IP addressand port combination that was determined to be the best match, the'list' in the remaining steps refers to the list of vhosts thatmatched, in the order they were in the configuration file.

我來(lái)簡(jiǎn)單翻譯,在vhost IP和端口吻合的情況下(就是你這里的*:80),apache會(huì)根據(jù)vhost配置文件中vhost的先后順序依次進(jìn)行匹配.

If the connection is using SSL, the server supports Server NameIndication, and the SSL client handshake includes the TLS extensionwith the requested hostname, then that hostname is used below justlike the Host: header would be used on a non-SSL connection.Otherwise, the first name-based vhost whose address matched is usedfor SSL connections. This is significant because the vhost determineswhich certificate the server will use for the connection.

如果是SSL連接,會(huì)根據(jù)TLS握手信息里面的SNI尋找主機(jī)名。如果不支持SNI,就匹配給第一個(gè)IP和端口(這里指的還是 *:80)吻合的vhost.

If the request contains a Host: header field, the list is searched forthe first vhost with a matching ServerName or ServerAlias, and therequest is served from that vhost. A Host: header field can contain aport number, but Apache always ignores it and matches against the realport to which the client sent the request.

如果HTTP頭部有Host信息,則匹配給第一個(gè)和ServerName或者ServerAlias吻合的虛擬主機(jī)。有的時(shí)候Host會(huì)包含端口信息,Apache不會(huì)鳥(niǎo)這個(gè)端口。

The first vhost in the config file with the specified IP address has the highest priority and catches any request to an unknown server name, or a request without a Host: header field (such as a HTTP/1.0 request).

如果都沒(méi)匹配上,扔給第一個(gè)IP端口(指的還是你的那個(gè)*:80)吻合的vhost

你訪(fǎng)問(wèn)的abc.com是第一個(gè)crm那個(gè)么?不是, 是127.0.0.1么(只有地址欄直接輸入127.0.0.1才算)? 不是,那就走默認(rèn)的,也就是第一個(gè)crm的配置。

回答2:

個(gè)人感覺(jué)serverName沒(méi)啥用,所以你這個(gè)按優(yōu)先適配原則,按80端口就直接是第一條規(guī)則。你要真想掛倆站點(diǎn),用端口號(hào)區(qū)分就好了~另外也可以看看文檔。中文文檔推薦譯者:金步國(guó)的。

回答3:

域名是用來(lái)解析為IP的,所以?xún)蓚€(gè)都是127.0.0.1而你的兩個(gè)端口同樣是80,只能訪(fǎng)問(wèn)第一個(gè)了

你把下面的的改為8080,用8080端口訪(fǎng)問(wèn)第二個(gè)

相關(guān)文章: