Proxy 설정시에 엄청난 트레픽과 이상한 요청!

Programming/Apache 2012.09.03 18:00

예전에 배포된 게임에 들어있는 주소로 뭔가 요청을 받던것을

새 도메인으로 옮기면서 기존것은 프록시를 걸었는데..


그 이후부터 서버에 엄청난 요청들이 쇄도 했다.


그 이유를 아래 블로그에서 상세히 밝혀주고있다.


너무 감사합니당.


http://theeye.pe.kr/entry/how-to-block-apache-with-proxy-remote-request


저작자 표시 비영리 변경 금지
신고
크리에이티브 커먼즈 라이선스
Creative Commons License

Apache-Tomcat proxy ajp

Programming/Apache 2012.02.08 01:56

1.버전에 맞는 아파치 소스 다운로드

wget http://apache.mirror.cdnetworks.com/httpd/httpd-2.0.63.tar.gz

 

2.압축 해제 후 module/proxy 디렉토리로 이동

tar xvzf httpd-2.0.63.tar.gz

/usr/local/src/httpd-2.0.63/modules/proxy


3.컴파일

/usr/local/apache/bin/apxs -i -a -c mod_proxy.c proxy_util.c

/usr/local/apache/bin/apxs -i -a -c mod_proxy_http.c proxy_util.c

/usr/local/apache/bin/apxs -i -a -c mod_proxy_connect.c proxy_util.c

/usr/local/apache/bin/apxs -i -a -c mod_proxy_ajp.c proxy_util.c ajp_header.c ajp_utils.c ajp_link.c ajp_msg.c


4. 결과

mod_proxy_ajp.so

mod_proxy_connect.so

mod_proxy_http.so

mod_proxy.so


5.httpd.conf 확인 & 수정

(1) 다음처럼 LoadModule에 추가되어있음을 확인

LoadModule proxy_module modules/mod_proxy.so

LoadModule proxy_connect_module modules/proxy_connect.so

LoadModule proxy_http_module modules/proxy_http.so

LoadModule proxy_ftp_module modules/mod_proxy_ajp.so


(2) 제일 하단에 다음처럼 추가

ProxyRequests On

ProxyVia On

<Proxy *>

Order deny,allow

Allow from all

</Proxy>


(3) vhost conf 파일이나 <Location> 안에 추가.

ProxyPass /pass ajp://localhost:8009/pass

ProxyPassReverse /pass ajp://localhost:8009/pass


(3-1) 같지만 다른 방법으로는 Rewrite를 사용하는 방법이 있음. ( http://httpd.apache.org/docs/current/mod/mod_rewrite.html )

RewriteEngine On

RewriteRule /pass(.*) ajp://localhost:8009/pass$1 [P]


6. 마지막으로 Tomcat server.xml 파일을 체크해줄것.

<Connector port="8009"

enableLookups="false" secure="true" URIEncoding="UTF-8"

tomcatAuthentication="false"

protocol="AJP/1.3" />

흐아~~~~ 새벽 2시다.-_-+ 

여담.
필요한 모듈들을 모두 안넣어주면 아래와 같은 에러가 발생한다.-_-;
제길 단순히 모듈이 없어서 나는 에러였다. 제길... 제길... 

[Wed Feb 08 01:03:15 2012] [warn] proxy: No protocol handler was valid for the URL /pass/test.html. If you are using a DSO version of mod_proxy, make sure the proxy submodules are included in the configuration using LoadModule.

저작자 표시 비영리 변경 금지
신고
크리에이티브 커먼즈 라이선스
Creative Commons License

[scrap]compile mod_proxy to existing apache (cpanel can do)

Programming/Apache 2009.06.04 17:20
d to-your-source-of-apache-build/src/modules/proxy

Bagi Cpanel servers:

cd /home/cpapachebuild/buildapache/apache_1.3.31/src/modules/proxy/

run command:

/usr/local/apache/bin/apxs -i -c *.c

mod_proxy has been created and placed straight
into the libexec directory.

add the following module directives to the httpd.conf:

LoadModule proxy_module libexec/mod_proxy.so
AddModule mod_proxy.c

Contoh penggunaannya dalam httpd.conf:

Proxypass / http://localhost:567/
ServerName your-server-name
ProxypassReverse / http://localhost:567/
ErrorLog /var/log/httpd/apps_error_log
CustomLog /var/log/httpd/apps_log combined


출처 : http://nustaffsite.gunadarma.ac.id/blog/akbar/2006/09/02/compile-mod_proxy-to-existing-apache-cpanel-can-do/

신고
크리에이티브 커먼즈 라이선스
Creative Commons License

'Programming > Apache' 카테고리의 다른 글

Apache-Tomcat proxy ajp  (0) 2012.02.08
[scrap]compile mod_proxy to existing apache (cpanel can do)  (0) 2009.06.04
Apache Tomcat Context 설정  (0) 2007.12.21
Apache2와 Tomcat5 연동하기  (0) 2007.11.26

Apache Tomcat Context 설정

Programming/Apache 2007.12.21 10:29

 

Apache Tomcat Configuration Reference

The Context Container

Printer Friendly Version
print-friendly
version
Introduction

The Context element represents a web application, which is run within a particular virtual host. Each web application is based on a Web Application Archive (WAR) file, or a corresponding directory containing the corresponding unpacked contents, as described in the Servlet Specification (version 2.2 or later). For more information about web application archives, you can download the Servlet Specification, and review the Tomcat Application Developer's Guide.

The web application used to process each HTTP request is selected by Catalina based on matching the longest possible prefix of the Request URI against the context path of each defined Context. Once selected, that Context will select an appropriate servlet to process the incoming request, according to the servlet mappings defined in the web application deployment descriptor file (which MUST be located at /WEB-INF/web.xml within the web app's directory hierarchy).

You may define as many Context elements as you wish. Each such Context MUST have a unique context path. In addition, a Context must be present with a context path equal to a zero-length string. This Context becomes the default web application for this virtual host, and is used to process all requests that do not match any other Context's context path.

For Tomcat 6, unlike Tomcat 4.x, it is NOT recommended to place <Context> elements directly in the server.xml file. This is because it makes modifing the Context configuration more invasive since the main conf/server.xml file cannot be reloaded without restarting Tomcat.

Context elements may be explicitly defined:

  • in the $CATALINA_HOME/conf/context.xml file: the Context element information will be loaded by all webapps
  • in the $CATALINA_HOME/conf/[enginename]/[hostname]/context.xml.default file: the Context element information will be loaded by all webapps of that host
  • in individual files (with a ".xml" extension) in the $CATALINA_HOME/conf/[enginename]/[hostname]/ directory. The name of the file (less the .xml) extension will be used as the context path. Multi-level context paths may be defined using #, e.g. context#path.xml. The default web application may be defined by using a file called ROOT.xml.
  • if the previous file was not found for this application, in an individual file at /META-INF/context.xml inside the application files
  • inside a Host element in the main conf/server.xml

In addition to explicitly specified Context elements, there are several techniques by which Context elements can be created automatically for you. See Automatic Application Deployment and User Web Applications for more information.

The description below uses the variable name $CATALINA_HOME to refer to the directory into which you have installed Tomcat 5, and is the base directory against which most relative paths are resolved. However, if you have configured Tomcat 5 for multiple instances by setting a CATALINA_BASE directory, you should use $CATALINA_BASE instead of $CATALINA_HOME for each of these references.

Attributes
Common Attributes

All implementations of Context support the following attributes:

Attribute Description

backgroundProcessorDelay

This value represents the delay in seconds between the invocation of the backgroundProcess method on this context and its child containers, including all wrappers. Child containers will not be invoked if their delay value is not negative (which would mean they are using their own processing thread). Setting this to a positive value will cause a thread to be spawn. After waiting the specified amount of time, the thread will invoke the backgroundProcess method on this host and all its child containers. A context will use background processing to perform session expiration and class monitoring for reloading. If not specified, the default value for this attribute is -1, which means the context will rely on the background processing thread of its parent host.

className

Java class name of the implementation to use. This class must implement the org.apache.catalina.Context interface. If not specified, the standard value (defined below) will be used.

cookies

Set to true if you want cookies to be used for session identifier communication if supported by the client (this is the default). Set to false if you want to disable the use of cookies for session identifier communication, and rely only on URL rewriting by the application.

crossContext

Set to true if you want calls within this application to ServletContext.getContext() to successfully return a request dispatcher for other web applications running on this virtual host. Set to false (the default) in security conscious environments, to make getContext() always return null.

docBase

The Document Base (also known as the Context Root) directory for this web application, or the pathname to the web application archive file (if this web application is being executed directly from the WAR file). You may specify an absolute pathname for this directory or WAR file, or a pathname that is relative to the appBase directory of the owning Host.

override

Set to true to have explicit settings in this Context element override any corresponding settings in the DefaultContext element associated with our owning Host. By default, settings in the DefaultContext element will be used.

If a symbolic link is used for docBase then changes to the symbolic link will only be effective after a Tomcat restart or by undeploying and redeploying the conext. A context reload is not sufficient.

privileged

Set to true to allow this context to use container servlets, like the manager servlet.

path

The context path of this web application, which is matched against the beginning of each request URI to select the appropriate web application for processing. All of the context paths within a particular Host must be unique. If you specify a context path of an empty string (""), you are defining the default web application for this Host, which will process all requests not assigned to other Contexts. The value of this field must not be set except when statically defining a Context in server.xml, as it will be inferred from the filenames used for either the .xml context file or the docBase.

reloadable

Set to true if you want Catalina to monitor classes in /WEB-INF/classes/ and /WEB-INF/lib for changes, and automatically reload the web application if a change is detected. This feature is very useful during application development, but it requires significant runtime overhead and is not recommended for use on deployed production applications. That's why the default setting for this attribute is false. You can use the Manager web application, however, to trigger reloads of deployed applications on demand.

wrapperClass

Java class name of the org.apache.catalina.Wrapper implementation class that will be used for servlets managed by this Context. If not specified, a standard default value will be used.

Standard Implementation

The standard implementation of Context is org.apache.catalina.core.StandardContext. It supports the following additional attributes (in addition to the common attributes listed above):

Attribute Description
allowLinking

If the value of this flag is true, symlinks will be allowed inside the web application, pointing to resources outside the web application base path. If not specified, the default value of the flag is false.

NOTE: This flag MUST NOT be set to true on the Windows platform (or any other OS which does not have a case sensitive filesystem), as it will disable case sensitivity checks, allowing JSP source code disclosure, among other security problems.

antiJARLocking

If true, the Tomcat classloader will take extra measures to avoid JAR file locking when resources are accessed inside JARs through URLs. This will impact startup time of applications, but could prove to be useful on platforms or configurations where file locking can occur. If not specified, the default value is false.

antiResourceLocking

If true, Tomcat will prevent any file locking. This will significantly impact startup time of applications, but allows full webapp hot deploy and undeploy on platforms or configurations where file locking can occur. If not specified, the default value is false.

Please note that setting this to true has some side effects, including the disabling of JSP reloading in a running server: see Bugzilla 37668.

Please note that setting this flag to true in applications that are outside the appBase for the Host (the webapps directory by default) will cause the application to be deleted on Tomcat shutdown. You probably don't want to do this, so think twice before setting antiResourceLocking=true on a webapp that's outside the appBase for its Host.

cacheMaxSize

Maximum size of the static resource cache in kilobytes. If not specified, the default value is 10240 (10 megabytes).

cacheTTL

Amount of time in milliseconds between cache entries revalidation. If not specified, the default value is 5000 (5 seconds).

cachingAllowed

If the value of this flag is true, the cache for static resources will be used. If not specified, the default value of the flag is true.

caseSensitive

If the value of this flag is true, all case sensitivity checks will be disabled. If not specified, the default value of the flag is true.

NOTE: This flag MUST NOT be set to false on the Windows platform (or any other OS which does not have a case sensitive filesystem), as it will disable case sensitivity checks, allowing JSP source code disclosure, among other security problems.

processTlds

Whether the context should process TLDs on startup. The default is true. The false setting is intended for special cases that know in advance TLDs are not part of the webapp.

swallowOutput

If the value of this flag is true, the bytes output to System.out and System.err by the web application will be redirected to the web application logger. If not specified, the default value of the flag is false.

tldNamespaceAware

If the value of this flag is true, the TLD files XML validation will be namespace-aware. If you turn this flag on, you should probably also turn tldValidation on. The default value for this flag is false, and setting it to true will incur a performance penalty.

tldValidation

If the value of this flag is true, the TLD files will be XML validated on context startup. The default value for this flag is false, and setting it to true will incur a performance penalty.

unloadDelay

Amount of ms that the container will wait for servlets to unload. If not specified, the default value of the flag is 2000 ms.

unpackWAR

If true, Tomcat will unpack all compressed web applications before running them. If not specified, the default value is true.

useNaming

Set to true (the default) to have Catalina enable a JNDI InitialContext for this web application that is compatible with Java2 Enterprise Edition (J2EE) platform conventions.

workDir

Pathname to a scratch directory to be provided by this Context for temporary read-write use by servlets within the associated web application. This directory will be made visible to servlets in the web application by a servlet context attribute (of type java.io.File) named javax.servlet.context.tempdir as described in the Servlet Specification. If not specified, a suitable directory underneath $CATALINA_HOME/work will be provided.

Nested Components

You can nest at most one instance of the following utility components by nesting a corresponding element inside your Context element:

  • Loader - Configure the web application class loader that will be used to load servlet and bean classes for this web application. Normally, the default configuration of the class loader will be sufficient.
  • Manager - Configure the session manager that will be used to create, destroy, and persist HTTP sessions for this web application. Normally, the default configuration of the session manager will be sufficient.
  • Realm - Configure a realm that will allow its database of users, and their associated roles, to be utilized solely for this particular web application. If not specified, this web application will utilize the Realm associated with the owning Host or Engine.
  • Resources - Configure the resource manager that will be used to access the static resources associated with this web application. Normally, the default configuration of the resource manager will be sufficient.
  • WatchedResource - The auto deployer will monitor the specified static resource of the web application for updates, and will reload the web application if is is updated. The content of this element must be a string.
Special Features
Logging

A context is associated with the org.apache.catalina.core.ContainerBase.[enginename].[hostname].[path] log category. Note that the brackets are actually part of the name, don't omit them.

Access Logs

When you run a web server, one of the output files normally generated is an access log, which generates one line of information for each request processed by the server, in a standard format. Catalina includes an optional Valve implementation that can create access logs in the same standard format created by web servers, or in any number of custom formats.

You can ask Catalina to create an access log for all requests processed by an Engine, Host, or Context by nesting a Valve element like this:

<Context path="/examples" ...>
  ...
  <Valve className="org.apache.catalina.valves.AccessLogValve"
         prefix="localhost_access_log." suffix=".txt"
         pattern="common"/>
  ...
</Context>

See Access Log Valve for more information on the configuration attributes that are supported.

Automatic Context Configuration

If you use the standard Context implementation, the following configuration steps occur automtically when Catalina is started, or whenever this web application is reloaded. No special configuration is required to enable this feature.

  • If you have not declared your own Loader element, a standard web application class loader will be configured.
  • If you have not declared your own Manager element, a standard session manager will be configured.
  • If you have not declared your own Resources element, a standard resources manager will be configured.
  • The web application properties listed in conf/web.xml will be processed as defaults for this web application. This is used to establish default mappings (such as mapping the *.jsp extension to the corresponding JSP servlet), and other standard features that apply to all web applications.
  • The web application properties listed in the /WEB-INF/web.xml resource for this web application will be processed (if this resource exists).
  • If your web application has specified security constraints that might require user authentication, an appropriate Authenticator that implements the login method you have selected will be configured.
Context Parameters

You can configure named values that will be made visible to the web application as servlet context initialization parameters by nesting <Parameter> elements inside this element. For example, you can create an initialization parameter like this:

<Context ...>
  ...
  <Parameter name="companyName" value="My Company, Incorporated"
         override="false"/>
  ...
</Context>

This is equivalent to the inclusion of the following element in the web application deployment descriptor (/WEB-INF/web.xml):

<context-param>
  <param-name>companyName</param-name>
  <param-value>My Company, Incorporated</param-value>
</context-param>

but does not require modification of the deployment descriptor to customize this value.

The valid attributes for a <Parameter> element are as follows:

Attribute Description
description

Optional, human-readable description of this context initialization parameter.

name

The name of the context initialization parameter to be created.

override

Set this to false if you do not want a <context-param> for the same parameter name, found in the web application deployment descriptor, to override the value specified here. By default, overrides are allowed.

value

The parameter value that will be presented to the application when requested by calling ServletContext.getInitParameter().

Environment Entries

You can configure named values that will be made visible to the web application as environment entry resources, by nesting <Environment> entries inside this element. For example, you can create an environment entry like this:

<Context ...>
  ...
  <Environment name="maxExemptions" value="10"
         type="java.lang.Integer" override="false"/>
  ...
</Context>

This is equivalent to the inclusion of the following element in the web application deployment descriptor (/WEB-INF/web.xml):

<env-entry>
  <env-entry-name>maxExemptions</param-name>
  <env-entry-value>10</env-entry-value>
  <env-entry-type>java.lang.Integer</env-entry-type>
</env-entry>

but does not require modification of the deployment descriptor to customize this value.

The valid attributes for an <Environment> element are as follows:

Attribute Description
description

Optional, human-readable description of this environment entry.

name

The name of the environment entry to be created, relative to the java:comp/env context.

override

Set this to false if you do not want an <env-entry> for the same environment entry name, found in the web application deployment descriptor, to override the value specified here. By default, overrides are allowed.

type

The fully qualified Java class name expected by the web application for this environment entry. Must be one of the legal values for <env-entry-type> in the web application deployment descriptor: java.lang.Boolean, java.lang.Byte, java.lang.Character, java.lang.Double, java.lang.Float, java.lang.Integer, java.lang.Long, java.lang.Short, or java.lang.String.

value

The parameter value that will be presented to the application when requested from the JNDI context. This value must be convertable to the Java type defined by the type attribute.

Lifecycle Listeners

If you have implemented a Java object that needs to know when this Context is started or stopped, you can declare it by nesting a Listener element inside this element. The class name you specify must implement the org.apache.catalina.LifecycleListener interface, and it will be notified about the occurrence of the coresponding lifecycle events. Configuration of such a listener looks like this:

<Context path="/examples" ...>
  ...
  <Listener className="com.mycompany.mypackage.MyListener" ... >
  ...
</Context>

Note that a Listener can have any number of additional properties that may be configured from this element. Attribute names are matched to corresponding JavaBean property names using the standard property method naming patterns.

Request Filters

You can ask Catalina to check the IP address, or host name, on every incoming request directed to the surrounding Engine, Host, or Context element. The remote address or name will be checked against a configured list of "accept" and/or "deny" filters, which are defined using the Regular Expression syntax supported by the Jakarta Regexp regular expression library. Requests that come from locations that are not accepted will be rejected with an HTTP "Forbidden" error. Example filter declarations:

<Context path="/examples" ...>
  ...
  <Valve className="org.apache.catalina.valves.RemoteHostValve"
         allow="*.mycompany.com,www.yourcompany.com"/>
  <Valve className="org.apache.catalina.valves.RemoteAddrValve"
         deny="192.168.1.*"/>
  ...
</Context>

See Remote Address Filter and Remote Host Filter for more information about the configuration options that are supported.

Resource Definitions

You can declare the characteristics of the resource to be returned for JNDI lookups of <resource-ref> and <resource-env-ref> elements in the web application deployment descriptor. You MUST also define the needed resource parameters as attributes of the Resource element, to configure the object factory to be used (if not known to Tomcat already), and the properties used to configure that object factory.

For example, you can create a resource definition like this:

<Context ...>
  ...
  <Resource name="jdbc/EmployeeDB" auth="Container"
            type="javax.sql.DataSource"
     description="Employees Database for HR Applications"/>
  ...
</Context>

This is equivalent to the inclusion of the following element in the web application deployment descriptor (/WEB-INF/web.xml):

<resource-ref>
  <description>Employees Database for HR Applications</description>
  <res-ref-name>jdbc/EmployeeDB</res-ref-name>
  <res-ref-type>javax.sql.DataSource</res-ref-type>
  <res-auth>Container</res-auth>
</resource-ref>

but does not require modification of the deployment descriptor to customize this value.

The valid attributes for a <Resource> element are as follows:

Attribute Description
auth

Specify whether the web Application code signs on to the corresponding resource manager programatically, or whether the Container will sign on to the resource manager on behalf of the application. The value of this attribute must be Application or Container. This attribute is required if the web application will use a <resource-ref> element in the web application deployment descriptor, but is optional if the application uses a <resource-env-ref> instead.

description

Optional, human-readable description of this resource.

name

The name of the resource to be created, relative to the java:comp/env context.

scope

Specify whether connections obtained through this resource manager can be shared. The value of this attribute must be Shareable or Unshareable. By default, connections are assumed to be shareable.

type

The fully qualified Java class name expected by the web application when it performs a lookup for this resource.

Resource Links

This element is used to create a link to a global JNDI resource. Doing a JNDI lookup on the link name will then return the linked global resource.

For example, you can create a resource link like this:

<Context ...>
  ...
  <ResourceLink name="linkToGlobalResource"
            global="simpleValue"
            type="java.lang.Integer"
  ...
</Context>

The valid attributes for a <ResourceLink> element are as follows:

Attribute Description
global

The name of the linked global resource in the global JNDI context.

name

The name of the resource link to be created, relative to the java:comp/env context.

type

The fully qualified Java class name expected by the web application when it performs a lookup for this resource link.

Transaction

You can declare the characteristics of the UserTransaction to be returned for JNDI lookup for java:comp/UserTransaction. You MUST define an object factory class to instantiate this object as well as the needed resource parameters as attributes of the Transaction element, and the properties used to configure that object factory.

The valid attributes for the <Transaction> element are as follows:

Attribute Description
factory

The class name for the JNDI object factory.


출처 : Apache Doc http://tomcat.apache.org/tomcat-6.0-doc/config/context.html



이 글은 스프링노트에서 작성되었습니다.

신고
크리에이티브 커먼즈 라이선스
Creative Commons License

'Programming > Apache' 카테고리의 다른 글

Apache-Tomcat proxy ajp  (0) 2012.02.08
[scrap]compile mod_proxy to existing apache (cpanel can do)  (0) 2009.06.04
Apache Tomcat Context 설정  (0) 2007.12.21
Apache2와 Tomcat5 연동하기  (0) 2007.11.26

Apache2와 Tomcat5 연동하기

Programming/Apache 2007.11.26 15:15

다른 참고 페이지 : http://php.chol.com/~vision82/tt/38



Apache2와 Tomcat5 연동하기

/*','[-]'); } /*]]>*/

작성자 : 박상현(브루펜시럽)

2006년 7월 9일 일요일 오전 5시즘 작성을 시작하였습니다. 기후는.. 제주도로 태풍이 북상중이라고 합니다.

1 서론


저는 사정상 PHP와 JSP 를 모두 처리해줄 필요가 있었기 때문에 Apache2/Tomcat5 연동 모델을 선택했습니다.

각자 처한 환경에 따라서 이 모델이 최선이 아닐 수도 있습니다. Tomcat5 의 standalone 모드도 고려해주시기 바랍니다. ^^

연동시 사용되는 connector 에는 mod_jserv, JK, JK2, mod_webapp or mod_proxy 등이 있습니다.

자세한 내막은 알지는 못하지만 jserv 와 mod_webapp 는 오래전부터 외면받아온 것 같고

JK2 는 개발자들의 흥미 부족을 이유로 개발이 중단되었습니다.

따라서 JK 와 mod_proxy 가 남는 데.. Apache2.2 부터는 mod_proxy_ajp 모듈이 제공됩니다.

국내에서는 해당 모듈을 이용한 연동 사례를 찾을 수 없어서 도전해보았습니다.


연동시 테스트된 환경은 다음과 같습니다.

OS Fedora core 5
Apache2.2 httpd-2.2.2-1.0
Tomcat5.5 tomcat5-5.5.15-1jpp_6fc
Java jdk 1.5.0_07

리눅스에 입문한지 얼마 안되어서 FC5 외의 환경에 대해서는 잘 알지 못하기 때문에

테스트에 사용된 설치 방법이 제공되지 않거나 적절하지 않을 수 있으며 언급된 경로등이 다를 수 있습니다.

find / -name {대상} 혹은 which {대상} 등으로 적절한 경로를 확인하시기 바랍니다.

2 Apache 2.2


  • yum 을 이용해서 관련 rpm 패키지들을 설치합니다.
# yum -y install httpd\*

  • httpd.conf 파일을 열어서 다음에 언급된 구문들을 찾아서 수정해줍니다.

    각 문구들이 의미하는 바에 대해서는 별도의 문서를 참고하여 주시기 바랍니다.

    제가 수정한 부분에 대해서만 언급하였습니다.
# vim /etc/httpd/conf/httpd.conf
서버관리자의 email 주소를 입력해줍니다. 에러페이지에 표시됩니다.
ServerAdmin root@localhost
주석을 풀어줍니다. 브라우저에서 http://127.0.0.1/~계정 으로 접속하면 /home/계정/public_html/ 에서 웹문서을 찾게 됩니다.
<IfModule mod_userdir.c>
    UserDir public_html
</IfModule>
언어별 우선 순위라고 합니다. ko 를 맨 앞으로 옮겨줍니다.
LanguagePriority ko en ca cs da de el eo es et fr he hr it ja ltz nl nn no pl pt pt-BR ru sv zh-CN zh-TW
UTF-8 을 사용하기엔 아직 환경이 충분히 조성되지 않은 것 같습니다. 인코딩 방식을 EUC-KR로 변경해줍니다.
AddDefaultCharset EUC-KR

  • 방화벽에서 80번 포트가 열렸는 지 확인합니다.
  • 아파치 데몬을 시작합니다.
# service httpd start

  • 브라우저에서 http://127.0.0.1/ 로 접속해봅니다. 참고로 페도라에서는 Fedora Core Test Page 가 떴습니다.
  • 아파치 데몬을 끝내려면 다음과 같이 입력합니다.
# service httpd stop

3 J2SE

Fedora core 5 에서는 JDK 5.0 을 rpm.bin 을 받아서 설치할 경우에 각종 경로 설정 문제가 발생하게 됩니다.

따라서 다음 싸이트에 나와있는 방법을 사용했습니다. http://www.fedorafaq.org/#java

그 외의 환경에서는 JavaInstallation 에 나와있는 설치 방법을 따르시기 바랍니다.


# yum -y install rpm-build

  • 다운 받은 JDK 파일을 빌드를 위해서 source 디렉토리로 이동 시킵니다.
# mv jdk-1_5_0_07-linux-i586-rpm.bin /usr/src/redhat/SOURCES/

# rpmbuild --rebuild java-1.5.0-sun-1.5.0.07-1jpp.nosrc.rpm
꽤 오래 작업합니다. 커피 드시면서 기다립니다.

  • 빌드된 rpm 을 설치합니다.
# yum -y localinstall /usr/src/redhat/RPMS/i586/java-1.5.0-sun-*
제 경우에는 nosigned 메시지와 함께 설치가 되지 않았습니다. 이 경우에는 rpm -Uvh 로 설치해주면 됩니다.

설치하는 패키지 중에 unixODBC-devel 패키지에 의존성이 있는 패키지가 있으니 먼저 설치해줍니다.
# yum -y install unixODBC-devel
# rpm -Uvh ~~ 

  • 설치가 정상적으로 되었는 지 확인해봅니다.
# java -version
java version "1.5.0_07" 과 같이 나오면 성공입니다.

만약 1.4.2 버전으로 나온다면 alternatives 에서 java 가 manual mode로 1.4.2 버전 디렉토리를 링크로 삼고 있을 수 있습니다.

다음과 같이 입력하시거나
# alternatives --auto java
다음과 같이 입력한 후에 1.5.0 버전 경로를 선택해주시면 됩니다.
# alternatives --confige java

4 Tomcat 5.5

  • yum 을 이용해서 관련 rpm 패키지들을 설치합니다.
# yum -y install tomcat5\*

  • 방화벽에서 8080포트를 열어줍니다.
  • 다음 파일을 수정합니다.
# vim /usr/share/tomcat5/bin/relink 
이 구문을 찾아서 -type d 옵션을 뒷편으로 옮겨준다.

find /var/lib/tomcat5/webapps -type d -mindepth 1 -maxdepth 2
find /var/lib/tomcat5/webapps -mindepth 1 -maxdepth 2 -type d

  • 다음 파일을 수정합니다.
# vim /usr/share/tomcat5/conf/workers.properties
#workers.tomcat_home=/var/tomcat
workers.tomcat_home=/usr/share/tomcat5

#workers.java_home=/opt/IBMJava2-13
workers.java_home=/usr/lib/jvm/java

  • tomcat5 admin툴에서 사용되는 계정 정보가 담겨 있습니다. 수정해줍니다. ( adminpassword 부분은 원하시는 패스워드를 입력하세요. )
# vim /usr/share/tomcat5/conf/tomcat-users.xml
<?xml version='1.0' encoding='utf-8'?>
<tomcat-users>
  <role rolename="tomcat"/>
  <role rolename="manager"/>
  <role rolename="admin"/>
  <user username="admin" password="adminpassword" roles="admin,manager,tomcat"/>
</tomcat-users>

  • 사용자 계정을 지원하기 위하여 수정해줍니다.
# vim /usr/share/tomcat5/conf/server.xml
<Host name="localhost" ...>
  ...
  <Listener className="org.apache.catalina.startup.UserConfig"
            directoryName="public_html"
            userClass="org.apache.catalina.startup.PasswdUserDatabase"/>
  ...
</Host>
적절한 호스트 아래에 다음의 Listener를 추가하게 되면 /etc/passwd 파일을 참고로 해서

http://127.0.0.1:8080/~user_account 로 들어온 접속을 /home/user_account/public_html 로 연결하여 준다고 합니다.


  • tomcat을 실행합니다.
# service tomcat5 start
브라우저에서 http://127.0.0.1:8080/로 접속해봅니다. 고양이가 나타나면 OK.

  • 이제 tomcat을 종료시킵니다.
# service tomcat5 stop

5 mod_proxy_ajp

mod_proxy_ajp.conf 에 기술된 mod_proxy_ajp 을 이용하는 방법은

다음과 같이 설정하여 줌으로서 특정 URL로 들어온 요청은 전부 톰캣이 처리하게 하는 것입니다.
ProxyPass /tomcat/ ajp://localhost:8009/
이 경우에는 jsp나 서블릿과 html 문서와 이미지등을 서로 경로를 구분해서 저장해야 본래의 목적을 달성할 수 있다는 문제점이 있습니다.

따라서 mod_rewirte 를 이용해서 .jsp 파일만 톰캣이 처리하는 방법을 사용하였습니다.

  • proxy_ajp.conf 파일을 열어서 다음과 같이 추가해줍니다.
# vim /etc/httpd/conf.d/proxy_ajp.conf
RewriteEngine On
#RewriteLog /root/mod_proxy_ajp.txt
#RewriteLogLevel 9
RewriteCond %{REQUEST_FILENAME} .jsp
RewriteRule (.*) ajp://localhost:8009$1 [P]

  • Tomcat5 의 홈디렉토리를 /var/www 로 변경해줍니다.
# cd /usr/share/tomcat5/webapps/ROOT
# mv ROOT ROOT.old
# ln -s /var/www/html /usr/share/tomcat5/webapps/ROOT
# cp -r /usr/share/tomcat5/webapps/ROOT.old/WEB-INF/ /usr/share/tomcat5/webapps/ROOT/WEB-INF

  • 아파치 데몬을 실행합니다.
# service httpd start

  • tomcat 을 실행합니다.
# service tomcat5 start

  • 테스트용으로 test.jsp 파일을 작성합니다.
# vim /var/www/html/test.jsp
<%@ page contentType="text/html; Charset=EUC-KR" %>
<%
out.println("Hello");
%>

6 기타 사항

페도라에서 service 명령어를 인식 못할 때는

일반 계정에서 root 계정으로 넘어갈 때 su 라고만 쳐줘서 /sbin 디렉토리가 PATH 에 추가되지 않은 경우일 수도 있습니다.
# . /etc/profile
하시면 PATH 가 적절하게 갱신되며 service 명령어가 제대로 인식될 것입니다. 다음부터는 su - 라고 입력하시는 게 바람직합니다.

뭐 제가 잘 몰라서 그랬습니다. 흐늘흐늘

7 참고 사이트

아래의 문서들 덕분에 무사히 항해를 마치고 라꾸라꾸 속으로 들어가봅니다. 감사합니다.

8 피드백

뭐라도 괜찮으니 한마디씩 써주고 가세요. ;ㅁ;

음 굿 ㅋ? -- ddakker

잘 읽고 갑니다. 수고에 감사드립니다. :-) -- allieus

이 글은 스프링노트에서 작성되었습니다.

신고
크리에이티브 커먼즈 라이선스
Creative Commons License

'Programming > Apache' 카테고리의 다른 글

Apache-Tomcat proxy ajp  (0) 2012.02.08
[scrap]compile mod_proxy to existing apache (cpanel can do)  (0) 2009.06.04
Apache Tomcat Context 설정  (0) 2007.12.21
Apache2와 Tomcat5 연동하기  (0) 2007.11.26


티스토리 툴바