⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 virtual-host.xtp

📁 解压在c盘
💻 XTP
字号:
<s1 title="Virtual Hosting"><summarylist/><s2 title='Standalone Virtual Hosting'><p>Each Resin instance can serve many virtual hosts.  The virtualhost will have its own servlets and documents.  For greater isolation,you can configure each virtual host to have its own JVM and you canhave all the virtual hosts controlled by a single web server.</p><p>Configuring the standalone server is the easiest and bestway of testing a virtual host configuration.  Theresin.conf is identical for Resin standalone and for Resin as aservlet runner.  So even when using an external web server, it's agood idea to test configuring with Resin standalone.</p><p>Each virtual host has its own <ahref='http-config.xtp#host'>host</a> block.  At very least, each hostwill define the <var/id/> specifying the host name and an<var/app-dir/> to specify the document root.</p><p>The following sample configuration defines two virtual hosts,gryffindor and slytherin, each with its own document directory.</p><example title='resin.conf'>&lt;http-server>  ...&lt;host id='gryffindor.caucho.com'>  &lt;app-dir>/home/www/gryffindor/docs&lt;/app-dir>  ...		    &lt;/host>&lt;host id='slytherin.caucho.com'>  &lt;app-dir>/home/www/slytherin/docs&lt;/app-dir>  ...		    &lt;/host></example><p>Browsing http://gryffindor.caucho.com/test.jsp will look for/home/www/gryffindor/docs/test.jsp.</p><p>Browsing http://slytherin.caucho.com/test.jsp will look for/home/www/slytherin/docs/test.jsp.</p></s2><s2 title='Virtual Hosts with Apache or IIS'><p>A common configuration uses virtual hosts with Apache or IIS.As usual, Apache or IIS will pass matching requests to Resin.</p><p>The Resin JVM configuration with Apache is identical to thestandalone configuration.  That similarity makes it easy to debug theApache configuration by retreating to Resin standalone if needed.</p><p>The <var/ServerName/> directive in Apache is vital to make Resin'svirtual hosting work.  When Apache passes the request to Resin, ittells Resin the <var/ServerName/>.  Without the <var/ServerName/>,Resin can get very confused which host to serve.</p><example title='httpd.conf'>LoadModule caucho_module /usr/local/apache/libexec/mod_caucho.soAddModule mod_caucho.cCauchoConfigFile /home/www/conf/resin.conf&lt;VirtualHost 127.0.0.1>  ServerName gryffindor.caucho.com&lt;/VirtualHost>&lt;VirtualHost 192.168.0.1>  ServerName slytherin.caucho.com&lt;/VirtualHost></example><note>You'll the LoadModule and AddModule must appear beforethe CauchoConfigFile for Apache to properly understand theCauchoConfigFile command.  If they're missing, Apache will sendan error.</note></s2><s2 title='JVM per Virtual Host'><p>In some ISP setups, it may make sense to assign a JVM for eachvirtual host.  The isolation of web-apps may not besufficient; each user needs a separate JVM.  In this configuration,each JVM needs its own srun-port and possibly its own srun-host.</p><p>In the most straightforward configuration, each JVM gets its ownresin.conf.  The resin.conf can use <ahref='resin-config.xtp#resin:include'>resin:include</a> to sharecommon configuration.</p><example title='httpd.conf'>&lt;VirtualHost 127.0.0.1>  ServerName gryffindor.caucho.com  CauchoConfigFile /home/www/config/gryffindor.conf&lt;/VirtualHost>&lt;VirtualHost 192.168.0.1>  ServerName slytherin.caucho.com  CauchoConfigFile /home/www/config/slytherin.conf&lt;/VirtualHost></example><p>Here's the corresponding gryffindor.conf</p><example title='gryffindor.conf'>&lt;caucho.com>&lt;http-server>  &lt;srun host=localhost port=8910/>  &lt;host id='www.gryffindor.com'>    &lt;app-dir>/home/www/gryffindor/htdocs&lt;/app-dir>    &lt;resin:include href='common.conf'/>  &lt;/host>&lt;/http-server>&lt;/caucho.com></example><example title='slytherin.conf'>&lt;caucho.com>&lt;http-server>  &lt;srun host=localhost port=8911/>  &lt;host id='www.slytherin.com'>    &lt;app-dir>/home/www/slytherin/htdocs&lt;/app-dir>    &lt;resin:include href='common.conf'/>  &lt;/host>&lt;/http-server>&lt;/caucho.com></example><p>You'll start each JVM separately.  With Unix, you mightdo something like:</p><example>unix> bin/httpd.sh -conf gryffindor.conf -pid gryffindor.pid startunix> bin/httpd.sh -conf slytherin.conf -pid slytherin.pid start</example><p>On Unix, the <var/-pid/> will let <var/resin/> knowwhich server to stop.</p><example>unix> bin/httpd.sh -conf gryffindor.conf -pid gryffindor.pid stopunix> bin/httpd.sh -conf slytherin.conf -pid slytherin.pid stop</example><p>When you restart the web server, you can look at<var/http://gryffindor/caucho-status/>and <var/http://slytherin/caucho-status/> to checkyour configuration.  Check that each virtual host is using the<var/srun-host/> and <var/srun-port/> that you expect.</p><s3 title='Why the host is necessary'><p>The &lt;host> block in gryffindor.conf and slytherin.conf isrequired for a subtle reason.  When Resin compiles JSP files, it generatesa Java class name.  Classes for different hosts get different class namesto prevent name collisions.</p><p>If gryffindor.conf and slytherin.conf omit the &lt;host>, Resin willgenerate the same class name for both hosts.  If both hosts also use the same<a href='resin-config.xtp#java'>work-dir</a>, one host will see the JSPfor the other host.</p></s3></s2><s2 title='IP-Based Virtual Hosting'><p>While Resin's virtual hosting is primarily aimed at named-basedvirtual hosts, it's possible to run Resin with IP-Based virtual hosts.</p><p>With IP virtual hosting, each &lt;http> block is configuredwith the virtual host name.  This configuration will override anyvirtual host supplied by the browser.</p><example>&lt;http-server>  &lt;http host='192.168.0.1' port='80'        virtual-host='slytherin.caucho.com'/>  ...  &lt;host id='slytherin.caucho.com'>    ...  &lt;/host>&lt;/http-server></example></s2></s1>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -