http와 https 모두에서 작동하는 가상 호스트를 어떻게 만듭니까?

http와 https 모두에서 작동하는 가상 호스트를 어떻게 만듭니까?

이것이 가상 호스트를 설정한 방법입니다.

<VirtualHost mysite> 
  <Directory "/Users/myusername/sitefolder"> 
    Options +FollowSymlinks
    AllowOverride All 
    Order Allow,Deny
    Allow from all
  </Directory> 
  DocumentRoot "/Users/myusername/sitefolder"
  ServerName mysite
  SSLEngine on
  SSLCertificateFile /Users/myusername/certs/server.crt
  SSLCertificateKeyFile /Users/myusername/certs/server.key
</VirtualHost>

이 구성을 사용하면 http가 아닌 https로만 사이트를 볼 수 있습니다. SSLEngine을 끄면 https로 내 사이트를 볼 수 없지만 http는 잘 작동합니다.

http와 https를 모두 사용하여 내 사이트를 볼 수 있도록 위 줄을 어떻게 조정합니까?

저는 OSX Lion을 사용하고 있지만 그다지 중요하다고 생각하지 않습니다.

감사해요.

답변1

따라서 두 개의 가상 호스트를 생성해야 합니다.

<VirtualHost mysite:80> 
  <Directory "/Users/myusername/sitefolder"> 
    Options +FollowSymlinks
    AllowOverride All 
    Order Allow,Deny
    Allow from all
  </Directory> 
  DocumentRoot "/Users/myusername/sitefolder"
  ServerName mysite
</VirtualHost>


<VirtualHost mysite:443> 
  <Directory "/Users/myusername/sitefolder"> 
    Options +FollowSymlinks
    AllowOverride All 
    Order Allow,Deny
    Allow from all
  </Directory> 
  DocumentRoot "/Users/myusername/sitefolder"
  ServerName mysite
  SSLEngine on
  SSLCertificateFile /Users/myusername/certs/server.crt
  SSLCertificateKeyFile /Users/myusername/certs/server.key
</VirtualHost>

첫 번째는 일반 HTTP호스트이고 두 번째는 트래픽 을 처리합니다 HTTPS.

답변2

Include또한 두 가상 호스트 간에 구성을 복제할 필요가 없도록 지시어를 사용하고 싶을 수도 있습니다 .http://httpd.apache.org/docs/2.2/mod/core.html#include.

관련 정보