apache 和 tomcat 的整合 备忘

Apache Tomcat V6.0 Tomcat 是一个轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP 程序的首选。 立即下载

apache 和 tomcat的整合,网上很多文章,我采用了proxy_ajp_module 的方式.但是我按照他们说的都没成功,后来无意中发现,

相关的配置要在 httpd.conf 和 httpd-vhosts.conf 里都要写才有效。不解!

我用的apache 2.2 ,tomcat 6.0.35 

httpd.conf

#
# This is the main Apache HTTP server configuration file.  It contains the
# configuration directives that give the server its instructions.
# See <URL:http://httpd.apache.org/docs/2.2> for detailed information.
# In particular, see 
# <URL:http://httpd.apache.org/docs/2.2/mod/directives.html>
# for a discussion of each configuration directive.
#
# Do NOT simply read the instructions in here without understanding
# what they do.  They're here only as hints or reminders.  If you are unsure
# consult the online docs. You have been warned.  
#
# Configuration and logfile names: If the filenames you specify for many
# of the server's control files begin with "/" (or "drive:/" for Win32), the
# server will use that explicit path.  If the filenames do *not* begin
# with "/", the value of ServerRoot is prepended -- so "logs/foo.log"
# with ServerRoot set to "E:/Apache2.2" will be interpreted by the
# server as "E:/Apache2.2/logs/foo.log".
#
# NOTE: Where filenames are specified, you must use forward slashes
# instead of backslashes (e.g., "c:/apache" instead of "c:\apache").
# If a drive letter is omitted, the drive on which httpd.exe is located
# will be used by default.  It is recommended that you always supply
# an explicit drive letter in absolute paths to avoid confusion.


#
# ServerRoot: The top of the directory tree under which the server's
# configuration, error, and log files are kept.
#
# Do not add a slash at the end of the directory path.  If you point
# ServerRoot at a non-local disk, be sure to point the LockFile directive
# at a local disk.  If you wish to share the same ServerRoot for multiple
# httpd daemons, you will need to change at least LockFile and PidFile.
#
ServerRoot "E:/Apache2.2"


#
# Listen: Allows you to bind Apache to specific IP addresses and/or
# ports, instead of the default. See also the <VirtualHost>
# directive.
#
# Change this to Listen on specific IP addresses as shown below to 
# prevent Apache from glomming onto all bound IP addresses.
#
#Listen 12.34.56.78:80
Listen 88


#
# Dynamic Shared Object (DSO) Support
#
# To be able to use the functionality of a module which was built as a DSO you
# have to place corresponding `LoadModule' lines at this location so the
# directives contained in it are actually available _before_ they are used.
# Statically compiled modules (those listed by `httpd -l') do not need
# to be loaded here.
#
# Example:
# LoadModule foo_module modules/mod_foo.so
#
LoadModule actions_module modules/mod_actions.so
LoadModule alias_module modules/mod_alias.so
LoadModule asis_module modules/mod_asis.so
LoadModule auth_basic_module modules/mod_auth_basic.so
#LoadModule auth_digest_module modules/mod_auth_digest.so
#LoadModule authn_alias_module modules/mod_authn_alias.so
#LoadModule authn_anon_module modules/mod_authn_anon.so
#LoadModule authn_dbd_module modules/mod_authn_dbd.so
#LoadModule authn_dbm_module modules/mod_authn_dbm.so
LoadModule authn_default_module modules/mod_authn_default.so
LoadModule authn_file_module modules/mod_authn_file.so
#LoadModule authnz_ldap_module modules/mod_authnz_ldap.so
#LoadModule authz_dbm_module modules/mod_authz_dbm.so
LoadModule authz_default_module modules/mod_authz_default.so
LoadModule authz_groupfile_module modules/mod_authz_groupfile.so
LoadModule authz_host_module modules/mod_authz_host.so
#LoadModule authz_owner_module modules/mod_authz_owner.so
LoadModule authz_user_module modules/mod_authz_user.so
LoadModule autoindex_module modules/mod_autoindex.so
LoadModule cache_module modules/mod_cache.so
#LoadModule cern_meta_module modules/mod_cern_meta.so
LoadModule cgi_module modules/mod_cgi.so
#LoadModule charset_lite_module modules/mod_charset_lite.so
#LoadModule dav_module modules/mod_dav.so
#LoadModule dav_fs_module modules/mod_dav_fs.so
#LoadModule dav_lock_module modules/mod_dav_lock.so
#LoadModule dbd_module modules/mod_dbd.so
LoadModule deflate_module modules/mod_deflate.so
LoadModule dir_module modules/mod_dir.so
#LoadModule disk_cache_module modules/mod_disk_cache.so
#LoadModule dumpio_module modules/mod_dumpio.so
LoadModule env_module modules/mod_env.so
#LoadModule expires_module modules/mod_expires.so
#LoadModule ext_filter_module modules/mod_ext_filter.so
#LoadModule file_cache_module modules/mod_file_cache.so
#LoadModule filter_module modules/mod_filter.so
LoadModule headers_module modules/mod_headers.so
#LoadModule ident_module modules/mod_ident.so
#LoadModule imagemap_module modules/mod_imagemap.so
LoadModule include_module modules/mod_include.so
#LoadModule info_module modules/mod_info.so
LoadModule isapi_module modules/mod_isapi.so
#LoadModule ldap_module modules/mod_ldap.so
#LoadModule logio_module modules/mod_logio.so
LoadModule log_config_module modules/mod_log_config.so
#LoadModule log_forensic_module modules/mod_log_forensic.so
LoadModule mem_cache_module modules/mod_mem_cache.so
LoadModule mime_module modules/mod_mime.so
#LoadModule mime_magic_module modules/mod_mime_magic.so
LoadModule negotiation_module modules/mod_negotiation.so
LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_ajp_module modules/mod_proxy_ajp.so
LoadModule proxy_balancer_module modules/mod_proxy_balancer.so
LoadModule proxy_connect_module modules/mod_proxy_connect.so
#LoadModule proxy_ftp_module modules/mod_proxy_ftp.so
LoadModule proxy_http_module modules/mod_proxy_http.so
#LoadModule proxy_scgi_module modules/mod_proxy_scgi.so
#LoadModule reqtimeout_module modules/mod_reqtimeout.so
#LoadModule rewrite_module modules/mod_rewrite.so
LoadModule setenvif_module modules/mod_setenvif.so
#LoadModule speling_module modules/mod_speling.so
#LoadModule ssl_module modules/mod_ssl.so
LoadModule status_module modules/mod_status.so
#LoadModule substitute_module modules/mod_substitute.so
#LoadModule unique_id_module modules/mod_unique_id.so
#LoadModule userdir_module modules/mod_userdir.so
#LoadModule usertrack_module modules/mod_usertrack.so
#LoadModule version_module modules/mod_version.so
#LoadModule vhost_alias_module modules/mod_vhost_alias.so


<IfModule !mpm_netware_module>
<IfModule !mpm_winnt_module>
#
# If you wish httpd to run as a different user or group, you must run
# httpd as root initially and it will switch.  
#
# User/Group: The name (or #number) of the user/group to run httpd as.
# It is usually good practice to create a dedicated user and group for
# running httpd, as with most system services.
#
User daemon
Group daemon


</IfModule>
</IfModule>


# 'Main' server configuration
#
# The directives in this section set up the values used by the 'main'
# server, which responds to any requests that aren't handled by a
# <VirtualHost> definition.  These values also provide defaults for
# any <VirtualHost> containers you may define later in the file.
#
# All of these directives may appear inside <VirtualHost> containers,
# in which case these default settings will be overridden for the
# virtual host being defined.
#


#
# ServerAdmin: Your address, where problems with the server should be
# e-mailed.  This address appears on some server-generated pages, such
# as error documents.  e.g. admin@your-domain.com
#
ServerAdmin lujing@mstchina.com


#
# ServerName gives the name and port that the server uses to identify itself.
# This can often be determined automatically, but we recommend you specify
# it explicitly to prevent problems during startup.
#
# If your host doesn't have a registered DNS name, enter its IP address here.
#
#ServerName server6.epp.mstchina.com:80


#
# DocumentRoot: The directory out of which you will serve your
# documents. By default, all requests are taken from this directory, but
# symbolic links and aliases may be used to point to other locations.
#
DocumentRoot "E:/Apache2.2/htdocs"


#
# Each directory to which Apache has access can be configured with respect
# to which services and features are allowed and/or disabled in that
# directory (and its subdirectories). 
#
# First, we configure the "default" to be a very restrictive set of 
# features.  
#
<Directory />
    Options FollowSymLinks
    AllowOverride None
    Order deny,allow
    Deny from all
</Directory>


#
# Note that from this point forward you must specifically allow
# particular features to be enabled - so if something's not working as
# you might expect, make sure that you have specifically enabled it
# below.
#


#
# This should be changed to whatever you set DocumentRoot to.
#
<Directory "E:/Apache2.2/htdocs">
    #
    # Possible values for the Options directive are "None", "All",
    # or any combination of:
    #   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
    #
    # Note that "MultiViews" must be named *explicitly* --- "Options All"
    # doesn't give it to you.
    #
    # The Options directive is both complicated and important.  Please see
    # http://httpd.apache.org/docs/2.2/mod/core.html#options
    # for more information.
    #
    Options Indexes FollowSymLinks


    #
    # AllowOverride controls what directives may be placed in .htaccess files.
    # It can be "All", "None", or any combination of the keywords:
    #   Options FileInfo AuthConfig Limit
    #
    AllowOverride None


    #
    # Controls who can get stuff from this server.
    #
    Order allow,deny
    Allow from all


</Directory>


#
# DirectoryIndex: sets the file that Apache will serve if a directory
# is requested.
#
<IfModule dir_module>
    DirectoryIndex index.html
</IfModule>


#
# The following lines prevent .htaccess and .htpasswd files from being 
# viewed by Web clients. 
#
<FilesMatch "^\.ht">
    Order allow,deny
    Deny from all
    Satisfy All
</FilesMatch>


#
# ErrorLog: The location of the error log file.
# If you do not specify an ErrorLog directive within a <VirtualHost>
# container, error messages relating to that virtual host will be
# logged here.  If you *do* define an error logfile for a <VirtualHost>
# container, that host's errors will be logged there and not here.
#
ErrorLog "logs/error.log"


#
# LogLevel: Control the number of messages logged to the error_log.
# Possible values include: debug, info, notice, warn, error, crit,
# alert, emerg.
#
LogLevel warn


<IfModule log_config_module>
    #
    # The following directives define some format nicknames for use with
    # a CustomLog directive (see below).
    #
    LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined
    LogFormat "%h %l %u %t \"%r\" %>s %b" common


    <IfModule logio_module>
      # You need to enable mod_logio.c to use %I and %O
      LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %I %O" combinedio
    </IfModule>


    #
    # The location and format of the access logfile (Common Logfile Format).
    # If you do not define any access logfiles within a <VirtualHost>
    # container, they will be logged here.  Contrariwise, if you *do*
    # define per-<VirtualHost> access logfiles, transactions will be
    # logged therein and *not* in this file.
    #
    CustomLog "logs/access.log" common


    #
    # If you prefer a logfile with access, agent, and referer information
    # (Combined Logfile Format) you can use the following directive.
    #
    #CustomLog "logs/access.log" combined
</IfModule>


<IfModule alias_module>
    #
    # Redirect: Allows you to tell clients about documents that used to 
    # exist in your server's namespace, but do not anymore. The client 
    # will make a new request for the document at its new location.
    # Example:
    # Redirect permanent /foo http://server6.epp.mstchina.com/bar


    #
    # Alias: Maps web paths into filesystem paths and is used to
    # access content that does not live under the DocumentRoot.
    # Example:
    # Alias /webpath /full/filesystem/path
    #
    # If you include a trailing / on /webpath then the server will
    # require it to be present in the URL.  You will also likely
    # need to provide a <Directory> section to allow access to
    # the filesystem path.


    #
    # ScriptAlias: This controls which directories contain server scripts. 
    # ScriptAliases are essentially the same as Aliases, except that
    # documents in the target directory are treated as applications and
    # run by the server when requested rather than as documents sent to the
    # client.  The same rules about trailing "/" apply to ScriptAlias
    # directives as to Alias.
    #
    ScriptAlias /cgi-bin/ "E:/Apache2.2/cgi-bin/"


</IfModule>


<IfModule cgid_module>
    #
    # ScriptSock: On threaded servers, designate the path to the UNIX
    # socket used to communicate with the CGI daemon of mod_cgid.
    #
    #Scriptsock logs/cgisock
</IfModule>


#
# "E:/Apache2.2/cgi-bin" should be changed to whatever your ScriptAliased
# CGI directory exists, if you have that configured.
#
<Directory "E:/Apache2.2/cgi-bin">
    AllowOverride None
    Options None
    Order allow,deny
    Allow from all
</Directory>


#
# DefaultType: the default MIME type the server will use for a document
# if it cannot otherwise determine one, such as from filename extensions.
# If your server contains mostly text or HTML documents, "text/plain" is
# a good value.  If most of your content is binary, such as applications
# or images, you may want to use "application/octet-stream" instead to
# keep browsers from trying to display binary files as though they are
# text.
#
DefaultType text/plain


<IfModule mime_module>
    #
    # TypesConfig points to the file containing the list of mappings from
    # filename extension to MIME-type.
    #
    TypesConfig conf/mime.types


    #
    # AddType allows you to add to or override the MIME configuration
    # file specified in TypesConfig for specific file types.
    #
    #AddType application/x-gzip .tgz
    #
    # AddEncoding allows you to have certain browsers uncompress
    # information on the fly. Note: Not all browsers support this.
    #
    #AddEncoding x-compress .Z
    #AddEncoding x-gzip .gz .tgz
    #
    # If the AddEncoding directives above are commented-out, then you
    # probably should define those extensions to indicate media types:
    #
    AddType application/x-compress .Z
    AddType application/x-gzip .gz .tgz


    #
    # AddHandler allows you to map certain file extensions to "handlers":
    # actions unrelated to filetype. These can be either built into the server
    # or added with the Action directive (see below)
    #
    # To use CGI scripts outside of ScriptAliased directories:
    # (You will also need to add "ExecCGI" to the "Options" directive.)
    #
    #AddHandler cgi-script .cgi


    # For type maps (negotiated resources):
    #AddHandler type-map var


    #
    # Filters allow you to process content before it is sent to the client.
    #
    # To parse .shtml files for server-side includes (SSI):
    # (You will also need to add "Includes" to the "Options" directive.)
    #
    #AddType text/html .shtml
    #AddOutputFilter INCLUDES .shtml
</IfModule>


#
# The mod_mime_magic module allows the server to use various hints from the
# contents of the file itself to determine its type.  The MIMEMagicFile
# directive tells the module where the hint definitions are located.
#
#MIMEMagicFile conf/magic


#
# Customizable error responses come in three flavors:
# 1) plain text 2) local redirects 3) external redirects
#
# Some examples:
#ErrorDocument 500 "The server made a boo boo."
#ErrorDocument 404 /missing.html
#ErrorDocument 404 "/cgi-bin/missing_handler.pl"
#ErrorDocument 402 http://server6.epp.mstchina.com/subscription_info.html
#


#
# MaxRanges: Maximum number of Ranges in a request before
# returning the entire resource, or one of the special
# values 'default', 'none' or 'unlimited'.
# Default setting is to accept 200 Ranges.
#MaxRanges unlimited


#
# EnableMMAP and EnableSendfile: On systems that support it, 
# memory-mapping or the sendfile syscall is used to deliver
# files.  This usually improves server performance, but must
# be turned off when serving from networked-mounted 
# filesystems or if support for these functions is otherwise
# broken on your system.
#
#EnableMMAP off
#EnableSendfile off


# Supplemental configuration
#
# The configuration files in the conf/extra/ directory can be 
# included to add extra features or to modify the default configuration of 
# the server, or you may simply copy their contents here and change as 
# necessary.


# Server-pool management (MPM specific)
#Include conf/extra/httpd-mpm.conf


# Multi-language error messages
#Include conf/extra/httpd-multilang-errordoc.conf


# Fancy directory listings
#Include conf/extra/httpd-autoindex.conf


# Language settings
#Include conf/extra/httpd-languages.conf


# User home directories
#Include conf/extra/httpd-userdir.conf


# Real-time info on requests and configuration
#Include conf/extra/httpd-info.conf


# Virtual hosts
Include conf/extra/httpd-vhosts.conf


# Local access to the Apache HTTP Server Manual
#Include conf/extra/httpd-manual.conf


# Distributed authoring and versioning (WebDAV)
#Include conf/extra/httpd-dav.conf


# Various default settings
#Include conf/extra/httpd-default.conf


# Secure (SSL/TLS) connections
#Include conf/extra/httpd-ssl.conf
#
# Note: The following must must be present to support
#       starting without SSL on platforms with no /dev/random equivalent
#       but a statically compiled-in mod_ssl.
#
<IfModule ssl_module>
SSLRandomSeed startup builtin
SSLRandomSeed connect builtin
</IfModule>




<IfModule mod_deflate.c>  
# 压缩级别
DeflateCompressionLevel 9  
# 压缩类型
SetOutputFilter DEFLATE  
AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-javascript application/x-httpd-php
AddOutputFilter DEFLATE js css  
# 启用日志记录
#DeflateFilterNote Input instream  
#DeflateFilterNote Output outstream  
#DeflateFilterNote Ratio ratio  
#LogFormat '"%r" %{outstream}n/%{instream}n (%{ratio}n%%)' deflate  
#CustomLog logs/deflate_log.log deflate  
</IfModule>


#缓存
<IfModule mod_cache.c>
   <IfModule mod_mem_cache.c>
       CacheEnable mem /
       MCacheMaxObjectCount 20000
       MCacheMaxObjectSize 1048576
       MCacheMaxStreamingBuffer 65536
       MCacheMinObjectSize 10
       MCacheRemovalAlgorithm GDSF
       MCacheSize 131072
   </IfModule>
</IfModule>


#
ProxyPassMatch /*.html$ !
ProxyPassMatch /*.css$ !
#ProxyPassMatch /*.js$ !
ProxyPassMatch /*.gif$ !
ProxyPassMatch /*.jpg$ !
ProxyPassMatch /*.png$ !
ProxyPassMatch /*.mp3$ !


#Show balancer-manager
#<Location /balancer-manager>
#  SetHandler balancer-manager
#  Order allow,deny
#  Allow from all
#</Location>


ProxyRequests Off


#Configure members for cluster
<Proxy balancer://ow>
  BalancerMember ajp://127.0.0.1:8009  loadfactor=1 route=tomcat1
  #BalancerMember ajp://127.0.0.1:9009  loadfactor=1 route=tomcat2
  ProxySet stickySession=JSESSIONID|jsessionid
</Proxy>


#Do not proxy balancer-manager
ProxyPass /balancer-manager !


#The actual ProxyPass
ProxyPass / balancer://ow/ stickySession=JSESSIONID|jsessionid nofailover=Off


#Do not forget ProxyPassReverse for redirects
ProxyPassReverse / ajp://127.0.0.1:8009
#ProxyPassReverse / ajp://127.0.0.1:9009 


httpd-vhosts.conf

#
# Virtual Hosts
#
# If you want to maintain multiple domains/hostnames on your
# machine you can setup VirtualHost containers for them. Most configurations
# use only name-based virtual hosts so the server doesn't need to worry about
# IP addresses. This is indicated by the asterisks in the directives below.
#
# Please see the documentation at 
# <URL:http://httpd.apache.org/docs/2.2/vhosts/>
# for further details before you try to setup virtual hosts.
#
# You may use the command line option '-S' to verify your virtual host
# configuration.


#
# Use name-based virtual hosting.
#
NameVirtualHost *:88


#
# VirtualHost example:
# Almost any Apache directive may go into a VirtualHost container.
# The first VirtualHost section is used for all requests that do not
# match a ServerName or ServerAlias in any <VirtualHost> block.
#
<VirtualHost *:88>
    ServerAdmin webmaster@dummy-host.epp.mstchina.com
    ServerName dummy-host.epp.mstchina.com
    ServerAlias www.dummy-host.epp.mstchina.com
    ErrorLog "logs/dummy-host.epp.mstchina.com-error.log"
    CustomLog "logs/dummy-host.epp.mstchina.com-access.log" common
    
    DocumentRoot "E:/webapps/ROOT"
    <Directory "E:/webapps/ROOT">
       Options FollowSymLinks
       AllowOverride None
       Order allow,deny
       Allow from all 
    </Directory>
    
    #Show balancer-manager
    #<Location /balancer-manager>
    #  SetHandler balancer-manager
    #  Order allow,deny
    #  Allow from all
    #</Location>
    
    ProxyRequests Off
    
    #Configure members for cluster
    <Proxy balancer://ow>
      BalancerMember ajp://127.0.0.1:8009  loadfactor=1 route=tomcat1
      #BalancerMember ajp://127.0.0.1:9009  loadfactor=1 route=tomcat2
      ProxySet stickySession=JSESSIONID|jsessionid
    </Proxy>
    
    
    
    #Do not proxy balancer-manager
    ProxyPass /balancer-manager !
    
    #The actual ProxyPass
    ProxyPass / balancer://ow/ stickySession=JSESSIONID|jsessionid nofailover=Off
    
    #Do not forget ProxyPassReverse for redirects
    ProxyPassReverse / ajp://127.0.0.1:8009
    #ProxyPassReverse / ajp://127.0.0.1:9009 
</VirtualHost>






server.xml

<?xml version='1.0' encoding='utf-8'?>
<!--
  Licensed to the Apache Software Foundation (ASF) under one or more
  contributor license agreements.  See the NOTICE file distributed with
  this work for additional information regarding copyright ownership.
  The ASF licenses this file to You under the Apache License, Version 2.0
  (the "License"); you may not use this file except in compliance with
  the License.  You may obtain a copy of the License at


      http://www.apache.org/licenses/LICENSE-2.0


  Unless required by applicable law or agreed to in writing, software
  distributed under the License is distributed on an "AS IS" BASIS,
  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  See the License for the specific language governing permissions and
  limitations under the License.
-->
<!-- Note:  A "Server" is not itself a "Container", so you may not
     define subcomponents such as "Valves" at this level.
     Documentation at /docs/config/server.html
 -->
<Server port="8005" shutdown="SHUTDOWN">


  <!--APR library loader. Documentation at /docs/apr.html -->
  <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" />
  <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html -->
  <Listener className="org.apache.catalina.core.JasperListener" />
  <!-- Prevent memory leaks due to use of particular java/javax APIs-->
  <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" />
  <!-- JMX Support for the Tomcat server. Documentation at /docs/non-existent.html -->
  <Listener className="org.apache.catalina.mbeans.ServerLifecycleListener" />
  <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" />


  <!-- Global JNDI resources
       Documentation at /docs/jndi-resources-howto.html
  -->
  <GlobalNamingResources>
    <!-- Editable user database that can also be used by
         UserDatabaseRealm to authenticate users
    -->
    <Resource name="UserDatabase" auth="Container"
              type="org.apache.catalina.UserDatabase"
              description="User database that can be updated and saved"
              factory="org.apache.catalina.users.MemoryUserDatabaseFactory"
              pathname="conf/tomcat-users.xml" />
  </GlobalNamingResources>


  <!-- A "Service" is a collection of one or more "Connectors" that share
       a single "Container" Note:  A "Service" is not itself a "Container", 
       so you may not define subcomponents such as "Valves" at this level.
       Documentation at /docs/config/service.html
   -->
  <Service name="Catalina">
  
    <!--The connectors can use a shared executor, you can define one or more named thread pools-->
    <!--
    <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" 
        maxThreads="150" minSpareThreads="4"/>
    -->
    
    
    <!-- A "Connector" represents an endpoint by which requests are received
         and responses are returned. Documentation at :
         Java HTTP Connector: /docs/config/http.html (blocking & non-blocking)
         Java AJP  Connector: /docs/config/ajp.html
         APR (HTTP/AJP) Connector: /docs/apr.html
         Define a non-SSL HTTP/1.1 Connector on port 8080
    -->
    <Connector port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" maxThreads="1000"
               compression="on" compressionMinSize="2048" noCompressionUserAgents="gozilla, traviata" 
               compressableMimeType="text/html,text/xml,text/javascript,text/css,text/plain"
               />
    <!-- A "Connector" using the shared thread pool-->
    <!--
    <Connector executor="tomcatThreadPool"
               port="8080" protocol="HTTP/1.1" 
               connectionTimeout="20000" 
               redirectPort="8443" />
    -->           
    <!-- Define a SSL HTTP/1.1 Connector on port 8443
         This connector uses the JSSE configuration, when using APR, the 
         connector should be using the OpenSSL style configuration
         described in the APR documentation -->
    <!--
    <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true"
               maxThreads="150" scheme="https" secure="true"
               clientAuth="false" sslProtocol="TLS" />
    -->


    <!-- Define an AJP 1.3 Connector on port 8009 -->
    <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" URIEncoding = "UTF-8" maxThreads="1000"/>




    <!-- An Engine represents the entry point (within Catalina) that processes
         every request.  The Engine implementation for Tomcat stand alone
         analyzes the HTTP headers included with the request, and passes them
         on to the appropriate Host (virtual host).
         Documentation at /docs/config/engine.html -->


    <!-- You should set jvmRoute to support load-balancing via AJP ie :
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1">         
    --> 
    <Engine name="Catalina" defaultHost="localhost" jvmRoute="tomcat1">


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


      <!-- The request dumper valve dumps useful debugging information about
           the request and response data received and sent by Tomcat.
           Documentation at: /docs/config/valve.html -->
      <!--
      <Valve className="org.apache.catalina.valves.RequestDumperValve"/>
      -->


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


      <!-- Define the default virtual host
           Note: XML Schema validation will not work with Xerces 2.2.
       -->
      <Host name="localhost"  appBase="e:/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>



另外 ,301转发的配置:

在httpd.conf 里 打开 rewrite_moudle 的注释,在Directory里加上 

    Options Indexes FollowSymLinks
    AllowOverride All
    RewriteEngine on 
    RewriteRule ^(.*)$ http://www.xxx.com [R=301]



之前困扰的一个问题也解决了,记录下来备忘:

应用之前发布在epp目录里,想把它直接发布到根目录,之前的做法是在root目录里index.html里加了跳转:

<meta http-equiv="refresh" content="0;url=/epp">

这种方式对搜索引擎不友好。


301的方式最好。


但有个更简单的解决方法:

把应用直接发布到 e:/webapps/ROOT 目录,在apache httpd-vhosts.conf 里把DocumentRoot 设置为该 ROOT目录。在tomcat server.xml Host节点里设置 appBase="e:/webapps"


补充:

项目里用到了dwr,dwr会在/dwr下动态生成一些js,但是没有写入磁盘,所以apache访问不到。

在httpd.conf里找到这句话,注释掉,搞定!

#ProxyPassMatch /*.js$ !


Dify工作流自动化:如何用Trae AI助手10倍提升你的开发效率(含避坑指南) 本文详细介绍了如何利用Trae AI助手自动化生成Dify工作流,实现开发效率的10倍提升。通过构建DSL示例库、精准需求描述和四步实战法,开发者可将重复的配置工作交给AI,快速生成可运行的工作流,并提供了关键的避坑指南。 阅读详情

相关推荐

手把手教你如何修改YOLO11的模型结构(以CBAM和可变性卷积为例)

YOLO11修改模型结构

2401_86807530的博客 1万+

SpringBoot启动Tomcat报错

提示信息 2019-08-13 15:54:20.881 ERROR 10048 --- [ main] o.a.catalina.core.AprLifecycleListener : An incompatible version [1.1.33] of the APR based Apache Tomcat Native library is installed, w...

楚辉的博客 896

dq轴坐标系下的电路方程

dq轴坐标系下的电路方程 dq轴坐标系是一种常见的电路方程,但是再dq轴坐标系下电路元件的电压电流dq轴存在一定的耦合,本文针对三相电路推导了dq轴坐标系下的电路电路方程进行一个推导,首先先列出来派克变换的公式 派克变换 [AdAqA0]=23[cos⁡(θ)cos⁡(θ−2π/3)cos⁡(θ+2π/3)−sin⁡(θ)−sin⁡(θ−2π/3)−sin⁡(θ+2π/3)1/21/21/2][AaAbAc]\left[\begin{array}{c}A_d\\A_q\\A_0 \end{array}\ri

Mr.Young的博客 1万+

Tomcat处理HTTP请求过程分析

Tomcat处理HTTP请求过程分析 一、Tomcat是什么? Tomcat是一个web应用服务器,是一个Servlet/Jsp容器,主要负责将客户端请求传递给对应的Servlet,并且将Servlet的响应数据返回给客户端。 Tomcat是基于组件的服务器。 二、Tomcat体系结构 Tomcat是一个基于组件的服务器,它的构成组件都是可配置的。其各个组件都在Tomcat安装目录下的....

雷小涛的专栏 7298

汽车诊断服务(UDS——0x11服务解析)

ECU复位服务(0x11)详解:该服务支持硬件/钥匙开关/软件三种复位类型(0x01-0x03),复位前需发送肯定响应。请求格式为11+子功能,响应含51+子功能。典型应用需配合安全访问流程,测试时需监控CAN总线通信及DTC状态。复位后ECU将返回默认会话,期间不处理任何诊断请求。服务在编程会话且安全解锁后执行,硬复位会初始化存储数据。

从事汽车行业 979

桁架 拓扑优化 matlab程序_拓扑优化在结构轻量化及板壳加筋肋最优布置的应用...

1 拓扑优化简介材料的有效利用一直都是人类追求的目标,也是许多研究领域不变的话题,并伴随着结构优化理论和方法的产生而发展。结构优化设计通常分为三个层次:(1)拓扑优化:在一个确定的连续区域内寻求结构内部非实体区域位置和数量的最佳配置,寻求结构中的构件布局及节点联结方式最优化,使结构能在满足应力、位移等约束条件下,将外载荷传递到结构支撑位置,同时使结构的某种性态指标达到最优;(2)形状优化:指在保持...

weixin_39525355的博客 1877

apache,tomcat缓慢的http拒绝服务攻击修改办法

在httpd.conf中添加 LoadModule reqtimeout_module modules/mod_reqtimeout.so 查看是否存在mod_reqtimeout.so模块 [root@localhost ~]# rpm -ql httpd |grep .so /usr/lib64/httpd/modules/mod_reqtimeout.so 添加配置 [root@localhost ~]# vi /etc/httpd/conf/httpd.conf <IfModule reqt

luminous_you的博客 7679

CGAL 网格等高线计算

CGAL 网格等高线计算

dayuhaitang1的博客 452

Django出现HTTP_HOST header: ‘testserver‘. You may need to add ‘testserver‘ to ALLOWED_HOSTS.

1、找到guest项目下的settings.py 添加host地址或者通配 ALLOWED_HOSTS = [‘127.0.0.1’,‘localhost’, ‘testserver’]或者ALLOWED_HOSTS = [’*’]

Ben_zhangxw的博客 418

【立创EDA-PCB设计基础】4.模块化布局

本文对本专栏绘制的原理图进行模块化布局,首先进行预布局(将每个模块放一起),然后进行精细化布局(按照原理图来精细化布局)。

嵌入式阿齐Archie 3万+

基于STM32、HAL库的MCP4013T-103E/CH 数字电位器驱动程序设计

define MCP4013_I2C_ADDR (0x5F << 1) // HAL库使用7位地址左移1位,或直接使用0xBE/0xBF。#include "i2c.h" // 包含你的I2C初始化相关的头文件,例如由CubeMX生成的 i2c.h。大于127的值会被截断。// MCP4013的读操作:主机发起读取请求,从机返回当前滑片位置的一个字节。// 使用HAL_I2C_Master_Transmit直接发送数据。// 使用HAL_I2C_Master_Receive读取一个字节。

corlin6688的博客 126

Java Tomcat7性能监控与优化详解

1. 目的 通过优化tomcat提高网站的并发能力。 2. 服务器资源 服务器所能提供CPU、内存、硬盘的性能对处理能力有决定性影响。 3. 优化配置 3.1. 配置tomcat管理员账户 在conf/ tomcat-users.xml下添加用户: <role rolename="manager"/> <role rolename="m...

dengwan3818的博客 348

【PCL点云配准】位姿估计

本文介绍了PCL(Point Cloud Library)中TransformationEstimation模块的核心算法原理和实现方法。该模块通过多种子类(如SVD、LM、双四元数等)提供点云配准功能,支持2D/3D刚性变换估计。主要内容包括:1)各类变换估计算法的数学原理和实现细节;2)点对点/点对面两种误差度量方法;3)线性闭式解和非线性迭代两种求解方式;4)变换验证机制;5)基于三点法的完整代码示例。该模块广泛应用于SLAM、三维重建等领域,为点云配准提供了高效可靠的解决方案。

yijiujiusan的博客 241

Apache+Tomcat+mod_rewrite的整合

今天弄了个Apache+tomcat整合,及mod_rewrite的URL重写。记录下作为个备忘: 首先:安装Apache2.2.10及tomcat6.0.15(我安装的版本) 配置Apache:修改conf/httpd.conf文件,增加以下内容(下载mod_jk.so文件,并拷贝到modules文件夹下) [code="java"]# load mod_jk LoadModule j...

kane8202的博客 515

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

Apache2(httpd)和Tomcat区别

记录备忘 1. Apache是web服务器,Tomcat是应用(java)服务器,它只是一个servlet容器,是Apache的扩展。 2. Apache和Tomcat都可以做为独立的web服务器来运行,但是Apache不能解释java程序(jsp,serverlet)。 3. Apache是普通服务器,本身只支持html即普通网页。不过可以通过插件支持php,还可以与Tomcat连通(单向

Fly2Leo的专栏 2169

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

在httpd.conf中使用反向代理整合apache与tomcat

篇语 网上关于这方面的环境搭建文章数不胜数,作为备忘,我仅记录下本博客搭建的全部过程,以及本人在搭建过程中遇到的问题与思考。我对php是完全陌生的,但作为一个java研发攻城师,要认真弄起来也不是什么难事。 配置坏境前,我购买了阿里云的弹性计算云主机,作为我的博客托管机器。本来想用radhat,但阿里云提供的redhat系统干净的连gcc都没,折腾半天,果断放弃并更换成CentOS。CentO

u012485320的专栏 1406

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

Apache+tomcat集群 简易版环境搭建

今天闲来无事,就想自己搭建个tomcat集群环境试试. 网上这种例子很多,不过也是走了一些弯路,最后终于成功.记录下来.做个备忘. 主要分几步: 一) apache安装 二)  apache,tomcat整合 三)  集群配置 一): apache安装 apache http server 目前最新版是2.4.17 , 官网提供下载的是源文件,还要编译后才能用, 所以我

能写下来,理解才会更深 737

apache+tomcat 负载均衡

  说明:本文只是对apache 与tomcat 整合的过程,做个备忘记录,别无其他   系统环境:本操作在windows7 环境下实验,其它配置大致;     软件下载: apache下载:http://httpd.apache.org/download.cgi#apache22  (这里使用的是httpd-2.2.19-win32-x86-no_ssl) tomcat 下载:h...

u012828988的博客 166

CentOS-7中部署apache-tomcat

备忘录:练习,即可。 本例环境: 操作系统:CentOS-7-x86_64-DVD-1908 JDK:JDK 1.7 安装包:jdk-7u80-linux-x64.rpm 远程连接工具:SecureCRT 8.0 下载地址:https://archive.apache.org/dist/tomcat/ 1.使用SecureCRT将文件...

zhangbeizhen18的博客 415

apache2.2与tomcat6.x+mod_jk整合

匆忙写下备忘: 环境: CentOs 5.6 jdk 1.6              httpd.conf配置:       #定义目录访问权限     &lt;Directory "/usr/local/apache-tomcat-6.0.33/webapps/sims"&gt;               AllowOverride None              ...

171

自己备忘,摘抄他人的

mod_jk Apache与Tomcat整合(包含各个版本) (2012-06-10 10:59:25)转载▼标签: mod_jk tomcat整合 it 分类: 编码测试Apache与Tomcat两个模块的链接整合。因为mod_jk的版本匹配问题,差点搞死我,在这里,把经验共享给大家: 这个网址中,mod_jk各种版本的都有:(windows/linux 都有)http://archive.a...

weixin_34318272的博客 84

mac os 下tomcat apr 警告解决方法

The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path:...tomcat可以整合本地apr,在处理静态资源的时候速度更快,总而言之就是使用本地的apr库提升处理效率。在网

jackhjb的专栏 5133

Tomcat 7.0环境配置

Tomcat 是Apache 软件基金会 的Jakarta项目中的一个核心项目,由 Apache 、Sun和其他一些公司以及个人共同开发而成。Tomcat 服务器是一个免费的开放源代码的Web 应用服务器,属于轻量级应用服务器,在中小型系统和并发访问用户不是很多的场合下被普遍使用,是开发和调试JSP 程序的首选。因为Tomcat 技术先进、性能稳定,而且免费,因而深受Java爱好者的喜爱并得到了部分软件开发商的认

朝 花 有 露* 2048

【整合】JDK6 + ECLIPSE3.4.2 + TOMCAT6.0.24 + AXIS2_1.4.1 开发环境的搭建

<br /><br />万事开头难,为这个东西折腾了一天。为自己作备忘,也为他人少走弯路,写下此文。<br />1.安装JDK6<br />  并设置环境变量 JAVA_HOME,path,class<br />  本文的安装路径为: D:/Tools/JDK6<br />  故设置:JAVA_HOME=D:/Tools/JDK6<br />          path=%JAVA_HOME%/bin;<br />          classpath=.;%JAVA_HOME%/lib;%JAVA_HOM

xinew的专栏 1080

Axis2;wsdl生成客户端和serverJava代码

【整合】JDK6 + Eclipse3.4.2 + Tomcat6.0.24 + Axis2_1.4.1 开发环境的搭建 万事开头难,为这个东西折腾了一天。为自己作备忘,也为他人少走弯路,写下此文。 1.安装JDK6   并设置环境变量 JAVA_HOME,pa

欧阳天涵的专栏 9989

在ubuntu上搭建java开发环境

最近公司决定使用linux作为操作系统,上个星期花了点时间终于配好了,有google就是好,参考了很多帖子,现写下文章备忘,省得下次装的时候到处找了。 版本:ubuntu server 7.10 目标环境: java tomcat apache mysql jspwiki 1.首先去官方网站[url]http://www.ubuntu.com/getubuntu/download[/ur...

像C罗一样努力 184
上一篇: svn 迁移、升级
下一篇: Quartz 报错,改用Spring task
yanjunlu
博客等级 码龄22年 9粉丝 17原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值