아파치 리다이렉션 질문입니다.

sosiq의 이미지

conf 파일에서
<Directory "/var/www/html">
Options FollowSymLinks
AllowOverride None
Order allow,deny
Allow from all
Deny from 192.168.1.1
</Directory>
이 설정으로 IP 192.168.1.1에서 아파치 서비스를 요청하면 거절을 하도록 설정하였습니다. 거절되면 아래에 ErrorDocument 403 뒷 부분에 있는 파일이 출력이 됩니다.
<LocationMatch "^/$>
Options -Indexes
ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var
</LocationMatch>
제가 알고 싶은 것은 "^/$ 의미와 192.168.1.1 사용자가 아파치 서비스를 요청할 시 /home/*/www/index.html 파일을 출력하는 방법 그리고 다른 웹 서버에 있는 페이지를 보여주는 방법 입니다.

wariua의 이미지

"^/$"의 의미:
http://httpd.apache.org/docs/1.3/mod/core.html#locationmatch
^/$는 루트경로를 의미하는 정규표현식(regular expression)입니다. "^"는 문자열의 시작, "$"는 문자열의 끝을 의미하므로 "^/$"는 (앞뒤에 다른 경로나 파일 이름이 붙어있지 않은) "/"를 뜻합니다.

<LocationMatch "^/$">


<Location />

과 동일합니다.

IP 주소로 다른 문서 보여주기
대략 rewrite 규칙으로 가능하지 않을까 싶습니다. /home/some_user/www/ 디렉터리를 http://server.name.net/some_user/로 접근가능하도록 설정하고서 (필요에 따라 192.168.1.1만 접근 가능하도록 하고서)

RewriteCond %{REMOTE_ADDR} ^192\.168\.1\.1$
RewriteRule ^/$ /some_user/index.html [L]

정도 해주시면 되지 않을까 합니다. (여기에서도 정규표현식이 쓰였습니다.) 이 경우 /var/www/html 에 대해 192.168.1.1을 막은 걸 풀어주어야 하는지는 저도 잘 모르겠습니다. 다른 서버로 redirection 시켜주시는 것도 마찬가지로 가능합니다. 자세한 내용은 Apache 1.3 URL Rewriting Guide에...

$PWD `date`

익명 사용자의 이미지

"^/$ 이 의미부터 이해가 안갑니다...
"^/$" 아니라 "^/$ 입니다.
"^/$" 님이 설명하신 부분에서 ^시작해서 $ 끝나는 부분 /를 뜻 한다고 하셧는데 말이지요; 제가 이해 안가는 접은 ErrorDocument 403 /error/HTTP_FORBIDDEN.html.var 이 부분 입니다. 이 파일에 위치는 /var/www/error/HTTP_FORBIDDEN.html.var 입니다. 위에서 처럼 /를 뜻한다면 ErrorDocument 403 /var/www/error/HTTP_FORBIDDEN.html.var 이 되어야 하지 않을까요?

ip 주소로 다른 문서 보여주기에서..
RewriteCond %{REMOTE_ADDR} ^192\.168\.1\.1$
RewriteRule ^/$ /some_user/index.html [L]
이 설정이 무엇을 의미하는지 몰라서 어떻게 설정해야 할지;;
일단 설정은

<LocationMatch "^/$>
      Options -Indexes
      RewriteCond %{REMOTE_ADDR} ^192\.168\.1\.1$ 
      RewriteRule ^/home$ /apache/index.html [L]
</LocationMatch>

이런 식으러 설정을 하였는데 안되네요;
wariua의 이미지

글쎄요, 닫는 따옴표가 빠진 식이 어떤 의미가 될지는 저도 잘 모르겠습니다.

LocationMatch 태그에서 지정한 문자열("^/$")은 이전 글의 링크가 가리키는 문서를 보면 아시겠지만 파일 시스템의 경로가 아니라 URL을 뜻합니다. 그리고 무엇보다 ErrorDocument 지시자의 두 번째 인자는 매뉴얼의 해당 항목에 적혀 있듯이 URL 또는 문자열입니다.

rewirte 규칙의 설정법은 이전 글의 링크를 읽어보시면 됩니다. "apache rewirte"로 검색하면 한글 문서도 많이 나옵니다.

$PWD `date`

sosiq의 이미지

아!
URL을 뜻한다는 말을 듣고 다음과 같이 설정해 주었더니 리다이렉션이 되는군요!

<Directory "/var/www/html">
	Options	FollowSymLinks
	AllowOverride AuthConfig
	Order allow,deny
	Deny from 192.168.1
</Directory>

<LocationMatch "^/$>
	Options -Indexes
	ErrorDocument 403 http://www.yahoo.co.kr/
</Location>

이렇게 해주면 192.168.1 대역에서 서비스를 요청해 오면 야후에 웹페이지를 보여 주는군요. 이렇게 간단한걸 몇일씩이나 :(

많은 도움을 주신 wariua님 감사합니다~ :D

댓글 달기

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
이것은 자동으로 스팸을 올리는 것을 막기 위해서 제공됩니다.