단일 가상 호스트에 대한 Apache의 역방향 프록시

단일 가상 호스트에 대한 Apache의 역방향 프록시

전문:

여러 가상 호스트를 사용하여 공개적으로 액세스 가능한 서버를 구성했습니다. 하나의 가상 호스트에 대한 요청은 백엔드 서버로 전송되어야 합니다. 다른 모든 요청은 로컬에서 처리되어야 합니다.

문제:

모든 가상 호스트에 대한 요청은 프록시가 필요한 웹 사이트가 활성화되면 ProxyPass 지시문에 지정된 IP 주소로 전달됩니다. 다른 가상 호스트를 방문하려고 하면 프록시된 웹사이트에서 웹페이지를 가져옵니다. 프록시된 웹사이트를 비활성화하면 다른 모든 가상 호스트는 정상 작동을 재개하고 로컬로 제공됩니다.

구성:

가상 호스트에 대해 공개적으로 액세스 가능한 서버에 있는 구성: (다른 가상 호스트는 동일한 구성의 복사본입니다.)

<VirtualHost *:80>
  ServerName www.mainsite.com
  ServerAlias mainsite.com
  ServerAdmin [email protected]

  DirectoryIndex index.php
  DocumentRoot /var/www/mainsite.com

  <Directory />
    AllowOverride None
  </Directory>

  LogLevel info
  ErrorLog /var/log/mainsite.com_err.log
  CustomLog /var/log/mainsite.com_access.log combined
</VirtualHost>

가상 호스트를 프록시하기 위해 공개적으로 액세스 가능한 서버에 있는 구성은 다음과 같습니다.

<VirtualHost *:80>

  ServerName calendar.othersite.com
  ServerAdmin [email protected]

  ProxyRequests Off 

  <Location />
    ProxyPass http://192.168.0.1/
    ProxyPassReverse http://192.168.0.1/
  </Location>

  <Proxy>
   Order Allow,Deny
   Allow from all
  </Proxy>


  TransferLog /var/log/othersite.com_access.log
  ErrorLog /var/log/othersite.com_err.log
  CustomLog /var/log/othersite.com.log combined
  LogLevel debug
</VirtualHost>

답변1

노력하다

sudo ln -s /etc/apache2/mods-available/proxy.load /etc/apache2/mods-enabled
sudo ln -s /etc/apache2/mods-available/proxy_http.load /etc/apache2/mods-enabled
sudo /etc/init.d/apache2 restart

관련 정보