认真能把事做对,用心才能把事做好,专心、专注、心注未来。 声明:本博客内容除特别注明转载外全部是个人工作总结,转载时请注明出处!

服务器上存在多网卡时,服务的访问问题

上一篇 / 下一篇  2011-07-24 11:29:08 / 个人分类:原创

 服务器上存在多网卡时,服务的访问问题

1、  经常我们安装服务时,通常使用的单网卡的服务器,这时服务安装好后,直接启动tomcat

访问时,直接输入url,例如:http://10.40.33.16:17070/smcmanage/manager/index.jsp,就可以访问服务了

2、  如果服务安装在多网卡服务器上时(假设有两块网卡,其中一块网卡的地址是:10.40.33.16,另一块网卡的地址是10.40.16.194),这时服务安装好后,直接启动tomcat。

访问时,直接输入url,例如:http://10.40.33.16:17070/smcmanage/manager/index.jsp或http://10.40.16.194:17070/smcmanage/manager/index.jsp都可以访问服务

3、  如果服务安装在多网卡服务器上时(假设有两块网卡,其中一块网卡的地址是:10.40.33.16,另一块网卡的地址是10.40.16.194),因为这两个IP地址不在同一个网段,如果希望只允许通过http://10.40.33.16:17070/smcmanage/manager/index.jsp访问,不允许通过http://10.40.16.194:17070/smcmanage/manager/index.jsp访问,那么应该怎么来设置呢?

i、               首先设置linux系统中主机名配置,编辑hosts文件,增加IP地址对应的主机名

           vi  /etc/hosts,结果如下:

#

# hosts         This file describes a number of hostname-to-address

#               mappings for the TCP/IP subsystem.  It is mostly

#               used at boot time, when no name servers are running.

#               On small systems, this file can be used instead of a

#               "named" name server.

# Syntax:

#

# IP-Address  Full-Qualified-Hostname  Short-Hostname

#

 

127.0.0.1       localhost

 

# special IPv6 addresses

::1             localhost ipv6-localhost ipv6-loopback

 

fe00::0         ipv6-localnet

 

ff00::0         ipv6-mcastprefix

ff02::1         ipv6-allnodes

ff02::2         ipv6-allrouters

ff02::3         ipv6-allhosts

10.40.33.16     linux3316

10.40.16.194    linux16194 

 

 

 

 

 

 

i、               设置tomcat中的主机名,vi  /tomcat/conf/server.xml

如果主机名做如下配置,表示通过这台服务器的所有IP都可以访问服务

如果希望只允许通过http://10.40.33.16:17070/smcmanage/manager/index.jsp访问,不允许通过http://10.40.16.194:17070/smcmanage/manager/index.jsp访问,则把Host name 的值改成linux3316即可

  <!-- Define the default virtual host

           Note: XML Schema validation will not work with Xerces 2.2.

       -->

      <Host name="localhost"  appBase="webapps"

            unpackWARs="true" autoDeploy="true"

            xmlValidation="false" xmlNamespaceAware="false">

 

        <!-- 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 -->

        <!--

        <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs"

               prefix="localhost_access_log." suffix=".txt" pattern="common" resolveHosts="false"/>

        -->

 

      </Host>

    </Engine>

  </Service>

</Server>

TAG: Tomcat tomcat TOMCAT 单网卡 多网卡 服务

 

评分:0

我来说两句

Open Toolbar