<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title><![CDATA[运维进行时]]></title> 
<link>https://blog.liuts.com/index.php</link> 
<description><![CDATA[互联网运维与架构]]></description> 
<language>zh-cn</language> 
<copyright><![CDATA[运维进行时]]></copyright>
<item>
<link>https://blog.liuts.com/post//</link>
<title><![CDATA[nginx虚拟目录(alias与root的区别)]]></title> 
<author>root &lt;admin@yourname.com&gt;</author>
<category><![CDATA[Nginx]]></category>
<pubDate>Thu, 22 Jan 2009 14:47:04 +0000</pubDate> 
<guid>https://blog.liuts.com/post//</guid> 
<description>
<![CDATA[ 
	&nbsp;&nbsp;&nbsp;&nbsp;nginx貌似没有虚拟目录的说法，因为它本来就是完完全全根据目录来设计并工作的。<br/>如果非要给nginx安上一个虚拟目录的说法，那就只有alias标签比较“像”，干脆来说说alias标签和root标签的区别吧。<br/>最基本的区别：alias指定的目录是准确的，root是指定目录的上级目录，并且该上级目录要含有location指定名称的同名目录。另外，根据前文所述，使用alias标签的目录块中不能使用rewrite的break。<br/>说不明白，看下配置：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>location /abc/ &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;alias /home/html/abc/;<br/>&#125;<br/></div></div><br/>在这段配置下，http://test/abc/a.html就指定的是/home/html/abc/a.html。这段配置亦可改成<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>location /abc/ &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;root /home/html/;<br/>&#125;<br/></div></div><br/>这样，nginx就会去找/home/html/目录下的abc目录了，得到的结果是相同的。<br/>但是，如果我把alias的配置改成：<br/><div class="quote"><div class="quote-title">引用</div><div class="quote-content"><br/>location /abc/ &#123;<br/>&nbsp;&nbsp;&nbsp;&nbsp;alias /home/html/def/;<br/>&#125;<br/></div></div><br/>那么nginx将会从/home/html/def/取数据，这段配置还不能直接使用root配置，如果非要配置，只有在/home/html/下建立一个 def->abc的软link（快捷方式）了。<br/>一般情况下，在location /中配置root，在location /other中配置alias是一个好习惯。<br/>至于alias和root的区别，我估计还没有说完全，如果在配置时发现奇异问题，不妨把这两者换换试试。<br/>原文：<a href="http://www.sudone.com/nginx/nginx_alias.html" target="_blank">http://www.sudone.com/nginx/nginx_alias.html</a><br/><br/>自己实践总结：<br/>1、使用alias时目录名后面一定要加“/”<br/>2、nginx、resin当虚拟目录名与真实目录同名时，虚拟目录比真实目录优先级要高。<br/>3、前端nginx的虚拟目录与后端resin真实目录同名时，后端resin真实目录优先级要高(即使resin也配制了同名的别名)。<br/>4、nginx+resin/tomcat整合过程中，发现Nginx的虚拟目录不能正确解析jsp，待解决。<br/><br/>Tags - <a href="https://blog.liuts.com/tags/%25E8%2599%259A%25E6%258B%259F%25E7%259B%25AE%25E5%25BD%2595/" rel="tag">虚拟目录</a>
]]>
</description>
</item><item>
<link>https://blog.liuts.com/post//#blogcomment</link>
<title><![CDATA[[评论] nginx虚拟目录(alias与root的区别)]]></title> 
<author> &lt;user@domain.com&gt;</author>
<category><![CDATA[评论]]></category>
<pubDate>Thu, 01 Jan 1970 00:00:00 +0000</pubDate> 
<guid>https://blog.liuts.com/post//#blogcomment</guid> 
<description>
<![CDATA[ 
	
]]>
</description>
</item>
</channel>
</rss>