우분투에서 apache2, tomcat6 연동(proxy_ajp, rewrite 사용)문제..;

ossin의 이미지

설치후 jsp 파일을 엑세스하면 403 forbidden 에러가 뜹니다;
먼저 제가 설치하고 설정한 부분을 말씀드릴께요
우분투 8.10 에서 시냅틱 꾸러미 관리자로 apache2 tomcat6 php mysql jdk를 선택하여 설치하고(그외 gd, 수호신 관련 라이브러리 설치)

http://localhost/ =] it works!
http://localhost:8080/ =] it works! 와 밑에 설명 줄줄 나오고 examples 같은것 모두 정상적으로 링크됩니다(ROOT밑에 jsp파일만들고 접근하면 잘되구요)

그다음
sudo a2enmod proxy_ajp
sudo a2enmod rewrite
한 후 /etc/init.d/apache2 restart 해줬구요

/etc/apache2/sites-available/default 파일을 열어서 아래와 같이 수정했습니다

[VirtualHost *:80]
	ServerAdmin webmaster@localhost
 
	DocumentRoot /var/www/
***** 아래부분 추가 *******
	RewriteEngine On
	RewriteLog /var/log/apache2/mod_proxy_ajp.log
	RewriteLogLevel 9
	RewriteCond %{REQUEST_FILENAME} .jsp
	RewriteRule (.*) ajp://localhost:8009$1 [P]
****** 여기까지 ************
	[Directory /]
		Options FollowSymLinks
		AllowOverride None
	[/Directory]
	[Directory /var/www/]
		Options Indexes FollowSymLinks MultiViews
		AllowOverride None
		Order allow,deny
		allow from all
	[/Directory]
 
	ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
	[Directory "/usr/lib/cgi-bin"]
		AllowOverride None
		Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
		Order allow,deny
		Allow from all
	[/Directory]
 
	ErrorLog /var/log/apache2/error.log
 
	# Possible values include: debug, info, notice, warn, error, crit,
	# alert, emerg.
	LogLevel warn
 
	CustomLog /var/log/apache2/access.log combined
 
    Alias /doc/ "/usr/share/doc/"
    [Directory "/usr/share/doc/"]
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    [/Directory]
 
[/VirtualHost]

그다음 /etc/tomcat6/server.xml 파일을 열어서 아래같이 수정했습니다

[Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /] 이거 주석걸고
 
[Connector port="8009" protocol="AJP/1.3" maxThreads="150" minSpareThreads="25"
	maxSpareThreads="75" enableLookups="false" redirectPort="8443" acceptCount="100"
	debug="0" connectionTimeout="20000" disableUploadTimeout="true" URIEncoding="UTF-8" /] 이렇게 추가
 
      [Host name="localhost"  appBase="webapps"
            unpackWARs="true" autoDeploy="true"
            xmlValidation="false" xmlNamespaceAware="false"] 이것도 주석걸고
 
		[Host name="localhost" debug="0" appBase="/var/www" unpackWARs="true" autoDeploy="true"
	xmlValidation="false" xmlNamespaceAware="false"]
[Context path="" docBase="/var/www" debug="0" reloadable="false" crossContext="true" /] 이렇게 추가

그리고
/var/www 에
test.php
test.jsp
파일두개를 만들고 테스트 했는데요
php는 phpinfo를 잘 찍고
test.jsp 는
Forbidden
 
You don't have permission to access /index.jsp on this server.
Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4.1 with Suhosin-Patch Server at localhost Port 80

이렇게 뜹니다

그래서 /var/log/mod_proxy_ajp.log 파일을 봤는데요 정상적으로 넘겨주는것 같습니다
아래는 로그 내용입니다

127.0.0.1 - - [18/Mar/2009:23:01:05 +0900] [localhost/sid#b9ce1060][rid#b9eb7548/initial] (2) init rewrite engine with requested uri /index.jsp
127.0.0.1 - - [18/Mar/2009:23:01:05 +0900] [localhost/sid#b9ce1060][rid#b9eb7548/initial] (3) applying pattern '(.*)' to uri '/index.jsp'
127.0.0.1 - - [18/Mar/2009:23:01:05 +0900] [localhost/sid#b9ce1060][rid#b9eb7548/initial] (4) RewriteCond: input='/index.jsp' pattern='.jsp' =] matched
127.0.0.1 - - [18/Mar/2009:23:01:05 +0900] [localhost/sid#b9ce1060][rid#b9eb7548/initial] (2) rewrite '/index.jsp' -] 'ajp://localhost:8009/index.jsp'
127.0.0.1 - - [18/Mar/2009:23:01:05 +0900] [localhost/sid#b9ce1060][rid#b9eb7548/initial] (2) forcing proxy-throughput with ajp://localhost:8009/index.jsp
127.0.0.1 - - [18/Mar/2009:23:01:05 +0900] [localhost/sid#b9ce1060][rid#b9eb7548/initial] (1) go-ahead with proxy request proxy:ajp://localhost:8009/index.jsp [OK]

그런데
localhost:8080/test.jsp 로 접근하면 또 정상적으로 뜹니다
물론 test.jsp 파일은 /var/www 에만 있구요;

어느부분이 잘못됐는지.. 어느부분을 더 수정해줘야하는지 검색해도 힘드네요;;
고수님들 좀 도와주세요..ㅠㅠ

glay의 이미지


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

이부분 8080 으로 되어야 하는거 아닌가요?

--------------- 절취선 ------------------------
하늘은 스스로 삽질하는 자를 삽으로 팬다.

http://glay.pe.kr


--------------- 절취선 ------------------------
하늘은 스스로 삽질하는 자를 삽으로 팬다.

http://glay.pe.kr

ossin의 이미지

8080으로도 바꿔봤는데도 그러네요
관련 포스트들 보니 localhost:8080 으로 접속해도
저기다가는 8009 쓰더라구요
server.xml Connector 도 8080으로 바꿔야하나요?

glay의 이미지

그럼 server.xml 의 8080 에 대한 부분이 어떻게 설정이 되어 있던가요?

그부분도 보여주셔야 할듯합니다.
--------------- 절취선 ------------------------
하늘은 스스로 삽질하는 자를 삽으로 팬다.

http://glay.pe.kr


--------------- 절취선 ------------------------
하늘은 스스로 삽질하는 자를 삽으로 팬다.

http://glay.pe.kr

다콘의 이미지

일단 Rewrite관련 부분은 전부 주석처리 하시고
ProxyPass / ajp://localhost:8009/
추가하고
http://localhost/test.jsp 했을때 잘 되는지 확인해보세요.

ossin의 이미지

#	RewriteEngine On
#	RewriteLog /var/log/apache2/mod_proxy_ajp.log
#	RewriteLogLevel 9
#	RewriteCond %{REQUEST_FILENAME} .jsp
#	RewriteRule (.*) ajp://localhost:8009$1 [P]
 
	ProxyPass / ajp://localhost:8009/

이렇게 바꾸고 localhost/test.jsp 했는데 또

Forbidden
 
You don't have permission to access /test.asp on this server.
Apache/2.2.9 (Ubuntu) PHP/5.2.6-2ubuntu4.1 with Suhosin-Patch Server at localhost Port 80

이렇게 뜨네요..ㅠㅠ;

그리고 localhost:8080/test.jsp 나 localhost:8009/test.jsp 접근하면 아무것도 안뜨고 그냥 완료됩니다

localhost/test.jsp 를 웹브라우저에서 치면 -> 아파치가 받아서 jsp 파일인가 검사한후에 -> ajp 커넥터로 톰캣한테 전달하면
톰캣이 처리하고 -> server.xml 에 설정된 host(/var/www) 로 다시 보내주는건가요?

일단 ajp 커넥터로 ajp://localhost:8009/test.jsp 로 보내기는 하는거 같은데요(log 파일에서 보면..)
아무래도 톰캣이나 server.xml 이 잘못되서 그런게 아닌가 생각이 드는데..
초보라서 이 이상 생각은 힘드네요;

ossin의 이미지

리눅스 인데요..
 
apache + tomcat...
 
403에러가 나네요..:8080 포트를 붙이면 제대로 뜨는데....8080포트를 붙이면
Forbidden
 
You don't have permission to access / on this server.
 
 
Apache/1.3.27 Server at webvil.com Port 80
 
============================================================
해결했습니다.
최상위 디렉토리의 권한문제였는데..음.그래도 신기하네요..tomcat 8080port접속시에는 권한에 무관하게 통과했는데...그 외의 접속 포트는 걸리고..음--;

이런 글이 있어서 /var/www 보니 755 root 인데 문제가 있나요?;;

ossin의 이미지

error.log 를 보니 denied....

[Fri Mar 20 00:20:40 2009] [error] [client 127.0.0.1] client denied by server configuration: proxy:ajp://localhost:8009/index.jsp
[Fri Mar 20 00:20:40 2009] [error] [client 127.0.0.1] client denied by server configuration: proxy:ajp://localhost:8009/index.jsp
[Fri Mar 20 00:20:40 2009] [error] [client 127.0.0.1] client denied by server configuration: proxy:ajp://localhost:8009/index.jsp
[Fri Mar 20 00:20:40 2009] [error] [client 127.0.0.1] client denied by server configuration: proxy:ajp://localhost:8009/index.jsp
[Fri Mar 20 00:20:41 2009] [error] [client 127.0.0.1] client denied by server configuration: proxy:ajp://localhost:8009/index.jsp

거부하네요.. 왜 거부하는걸까요..ㅠㅠ
이게 문제인거 같은데..;

ossin의 이미지

구굴구굴신이 해결해줬어영;
저는 권한문제가 아니고 proxy.conf 설정문제였네요
답변주신 다콘님 glay님 감사드립니다(__)

hunt72kr의 이미지

해결하신 내용을 상세히 공유 해주시면 감사하겠습니다.

저도 비슷한 문제라서요.

댓글 달기

Filtered HTML

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

BBCode

  • 텍스트에 BBCode 태그를 사용할 수 있습니다. URL은 자동으로 링크 됩니다.
  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param>
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.

Textile

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • You can use Textile markup to format text.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Markdown

  • 다음 태그를 이용하여 소스 코드 구문 강조를 할 수 있습니다: <code>, <blockcode>, <apache>, <applescript>, <autoconf>, <awk>, <bash>, <c>, <cpp>, <css>, <diff>, <drupal5>, <drupal6>, <gdb>, <html>, <html5>, <java>, <javascript>, <ldif>, <lua>, <make>, <mysql>, <perl>, <perl6>, <php>, <pgsql>, <proftpd>, <python>, <reg>, <spec>, <ruby>. 지원하는 태그 형식: <foo>, [foo].
  • Quick Tips:
    • Two or more spaces at a line's end = Line break
    • Double returns = Paragraph
    • *Single asterisks* or _single underscores_ = Emphasis
    • **Double** or __double__ = Strong
    • This is [a link](http://the.link.example.com "The optional title text")
    For complete details on the Markdown syntax, see the Markdown documentation and Markdown Extra documentation for tables, footnotes, and more.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 사용할 수 있는 HTML 태그: <p><div><span><br><a><em><strong><del><ins><b><i><u><s><pre><code><cite><blockquote><ul><ol><li><dl><dt><dd><table><tr><td><th><thead><tbody><h1><h2><h3><h4><h5><h6><img><embed><object><param><hr>

Plain text

  • HTML 태그를 사용할 수 없습니다.
  • web 주소와/이메일 주소를 클릭할 수 있는 링크로 자동으로 바꿉니다.
  • 줄과 단락은 자동으로 분리됩니다.
댓글 첨부 파일
이 댓글에 이미지나 파일을 업로드 합니다.
파일 크기는 8 MB보다 작아야 합니다.
허용할 파일 형식: txt pdf doc xls gif jpg jpeg mp3 png rar zip.
CAPTCHA
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.