Apache 가상 호스트가 일관되게 작동하지 않습니다.

Apache 가상 호스트가 일관되게 작동하지 않습니다.

내 웹서버에는 클라이언트 IP 주소를 반환하는 것이 유일한 목표인 가상 호스트가 있습니다.

petrus@bzn:~$ cat /home/vhosts/domain.org/index.php
<?php echo $_SERVER['REMOTE_ADDR']; echo "\n" ?>

이는 특히 NAT가 관련된 경우 네트워킹 문제를 해결하는 데 도움이 됩니다. 따라서 도메인 이름 확인이 항상 가능한 것은 아니며 이 서비스는 IP 주소로 쿼리하는 경우에도 작동해야 합니다.

나는 이것을 이런 식으로 사용하고 있습니다 :

petrus@hive:~$ echo "GET /" | nc 88.191.133.41 80
191.51.4.55

petrus@hive:~$ echo "GET /" | nc ydct.org 80
191.51.4.55

router#more http://88.191.133.41/index.php
88.191.124.254

그러나 적어도 컴퓨터에서는 작동하지 않는 것으로 나타났습니다.

petrus@seth:~$ echo "GET /" | nc ydct.org 80
petrus@seth:~$

petrus@seth:~$ echo "GET /" | nc 88.191.133.41 80
petrus@seth:~$

제가 확인한 내용:

이는 ipv6과 관련이 없습니다.

petrus@seth:~$ echo "GET /" | nc -4 ydct.org 80
petrus@seth:~$ 

petrus@hive:~$ echo "GET /" | nc ydct.org 80
2a01:e35:ee8c:180:21c:77ff:fe30:9e36

netcat버전은 동일합니다(플랫폼 제외, i386 대 x64).

petrus@seth:~$ type nc
nc est haché (/bin/nc)
petrus@seth:~$ file /bin/nc
/bin/nc: symbolic link to `/etc/alternatives/nc'
petrus@seth:~$ ls -l /etc/alternatives/nc
lrwxrwxrwx 1 root root 15 2010-06-26 14:01 /etc/alternatives/nc -> /bin/nc.openbsd

petrus@hive:~$ type nc
nc est haché (/bin/nc)
petrus@hive:~$ file /bin/nc
/bin/nc: symbolic link to `/etc/alternatives/nc'
petrus@hive:~$ ls -l /etc/alternatives/nc
lrwxrwxrwx 1 root root 15 2011-05-26 01:23 /etc/alternatives/nc -> /bin/nc.openbsd

파이프 없이 사용할 때 작동합니다.

petrus@seth:~$ nc ydct.org 80
GET /
2a01:e35:ee8c:180:221:85ff:fe96:e485

그리고 파이프는 최소한 테스트 서비스( netcat1234/tcp에서 수신 대기하고 stdout으로 출력) 에서 작동합니다.

petrus@bzn:~$ nc -l -p 1234
GET /
petrus@bzn:~$

petrus@seth:~$ echo "GET /" | nc ydct.org 1234
petrus@seth:~$

netcat이 문제가 또는 와 더 관련이 있는지는 모르겠지만 Apache이 문제를 해결하는 데 도움이 되는 조언을 주시면 감사하겠습니다!

bzn서버이고 hive작동 중인 클라이언트이며 seth문제가 있는 클라이언트입니다.

편집: 배관에서도 작동 telnet하지만 telnet배관을 허용하지 않습니다.

MickeyB에 대한 답변의 두 번째 편집:

실제로 호스트 헤더는 전송되지 않지만 위의 호스트에서 볼 수 있듯이 Apache의 가상 호스트가 가상 호스트처럼 동작하도록 hive구성했습니다 .defaultydct.org

petrus@bzn:/etc/apache2/sites-available$ cat default
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName 88.191.133.41
        ServerAlias 2a01:e1b:1:132:1a0a:a9ff:fec8:f0a9
        DocumentRoot /home/vhosts/ydct.org/
</VirtualHost>

그러나 curl!

petrus@seth:~$ curl ydct.org
2a01:e35:ee8c:180:221:85ff:fe96:e485

apache2 -S게시 대상 의 출력http://pastebin.com/aSf446Jv

그런데 왜 작동하지 않는지 알고 싶습니다 netcat...

답변1

간단히 말해서, 실행 중인 netcat 버전입니다.

내 컴퓨터에서 다음과 같이 명령 문자열을 테스트했습니다.

맥 OS X 라이온:

yvaine:sqlite user$ echo -e "GET /" | nc 88.191.133.41 80
XX.XX.XX.168

FreeBSD:

[root@freebsd82 /usr/ports]# echo -e "GET /" | nc 88.191.133.41 80
XX.XX.XX.168

CentOS:

[root@kvm0001 ~]# echo -e "GET /" | nc 88.191.133.41 80
XX.XX.XX.168

데비안(버전 6)

root@debian:~# echo -e "GET /" | nc 88.191.133.41 80
XX.XX.XX.168

내가 Ubuntu "lucid"(당신이 분명히 실행하고 있는 것)에 도달하기 전까지는 다음을 얻었습니다.

root@ubuntu:~# echo -e "GET /" | nc 88.191.133.41 80
root@ubuntu:~# 

Ubuntu의 기본값은 nc.traditional(Debian의 기본값)이 아닌 nc.openbsd인 것 같습니다. 기존 버전을 사용하면 원하는 결과를 얻었습니다.

root@ubuntu:~# echo -e "GET /" | nc.traditional 88.191.133.41 80
XX.XX.XX.168

두 클라이언트 시스템 모두에 nc.openbsd가 있지만 동작이 다르다는 점이 궁금합니다. 물론, 그들 중 하나가 다른 버전의 nc.openbsd를 가지고 있거나 완전히 다른 버전의 Ubuntu를 가지고 있을 수도 있습니다. 어느 쪽이든 nc.openbsd 버전을 동기화하거나 nc.traditional로 전환할 수 있습니다.

답변2

나를 위해 작동합니다 :)

michael@challenger:~$ echo -e "GET /\n" | nc 88.191.124.41 80
<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>

가상 호스트를 공격하려는 경우 잘못 수행하고 있는 것입니다. 사용하려는 가상 호스트를 식별하려면 Host: 헤더를 보내야 합니다.

'내 IP는 무엇입니까' 서비스를 사용하는 가장 좋은 방법은 컬입니다. 안녕하세요, 제가 당신이 하고 있는 일을 할 때에도 같은 문제가 발생하는 것을 발견했습니다.

michael@challenger:~$ echo -e "GET /" | nc ip.mydomain.ca 80
michael@challenger:~$ curl ip.mydomain.ca
192.168.0.135


VHOST를 수정하세요!!!

michael@challenger:~$ curl -v 88.191.124.41
* About to connect() to 88.191.124.41 port 80 (#0)
*   Trying 88.191.124.41... connected
* Connected to 88.191.124.41 (88.191.124.41) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.21.3 (x86_64-pc-linux-gnu) libcurl/7.21.3 OpenSSL/0.9.8o zlib/1.2.3.4 libidn/1.18
> Host: 88.191.124.41
> Accept: */*
> 
< HTTP/1.1 200 OK
< Date: Fri, 25 Nov 2011 22:11:31 GMT
< Server: Apache/2.2.14 (Ubuntu)
< Last-Modified: Wed, 25 Aug 2010 08:11:38 GMT
< ETag: "840d09-b1-48ea16e57f5a6"
< Accept-Ranges: bytes
< Content-Length: 177
< Vary: Accept-Encoding
< Content-Type: text/html
< X-Pad: avoid browser bug
< 
<html><body><h1>It works!</h1>
<p>This is the default web page for this server.</p>
<p>The web server software is running but no content has been added, yet.</p>
</body></html>
* Connection #0 to host 88.191.124.41 left intact
* Closing connection #0

답변3

대기 시간을 설정하고 다시 시도하세요.

$ echo "GET /" | nc -w 3 88.191.124.41 80

관련 정보