現在的位置: 首頁 > 綜合 > 正文

win7下設置區域網能訪問本地tomcat伺服器

2014年10月30日 ⁄ 綜合 ⁄ 共 1589字 ⁄ 字型大小 評論關閉

今天碰到需要讓校園網(區域網,使用交換機)其他團隊成員的機子訪問自己機子的tomcat伺服器,本人正在使用的是剛出的tomcat8.0.

第一步:

<Engine name="Catalina" defaultHost="***">

      <!--For clustering, please take a look at documentation at:
          /docs/cluster-howto.html  (simple how to)
          /docs/config/cluster.html (reference documentation) -->
      <!--
      <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/>
      -->

      <!-- Use the LockOutRealm to prevent attempts to guess user passwords
           via a brute-force attack -->
      <Realm className="org.apache.catalina.realm.LockOutRealm">
        <!-- This Realm uses the UserDatabase configured in the global JNDI
             resources under the key "UserDatabase".  Any edits
             that are performed against this UserDatabase are immediately
             available for use by the Realm.  -->
        <Realm className="org.apache.catalina.realm.UserDatabaseRealm"
               resourceName="UserDatabase"/>
      </Realm>

      <Host name="***"  appBase="webapps"
            unpackWARs="true" autoDeploy="true">
		<!--<Context path="" docBase="/folder" debug="0" reloadable="true" crossContext="true"/>-->

        <!-- SingleSignOn valve, share authentication between web applications
             Documentation at: /docs/config/valve.html -->
        <!--
        <Valve className="org.apache.catalina.authenticator.SingleSignOn" />
        -->

        <!-- Access log processes all example.
             Documentation at: /docs/config/valve.html
             Note: The pattern used is equivalent to using pattern="common" -->
        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"
               prefix="localhost_access_log" suffix=".txt"
               pattern="%h %l %u %t "%r" %s %b" />

      </Host>
    </Engine>

上述片段是tomcat安裝目錄下conf/server.xml的部分代碼,***指的是本機ip,注釋的<context>可用來指定網站項目的目錄(用時去掉注釋)。

第二步:

windows防火牆->高級設置->(右側)新建規則,按照流程新建允許特定埠(如80,8080)

第三步:

windows防火牆->允許程序或功能通過防火牆,找到commons daemon service runner,勾選公用

至此,校園網內其他機子可以訪問本機webapps的應用了

抱歉!評論已關閉.