配置Virtualhost以在特定域

时间:2016-03-01 21:20:22

标签: apache virtualhost

我需要配置apache来重定向网站的文档根目录,只需要域名请求,例如

如果我在浏览器https://my.domain.com上输入,我需要查看网站

如果我在浏览器https://ip_server上输入,我需要查看apache礼貌页面(Main DocumentRoot apache)

我尝试在VirtualHost指令中应用域名,但我有一个SSL错误

我的文件vhost(有效):

<VirtualHost *:443>
     ServerName my.domain.com
     RewriteEngine On
     RewriteOptions Inherit
     JkMount       /idp/* worker1

     DocumentRoot "/var/www/html/mydomain"

ErrorLog logs/ssl_error_log
CustomLog logs/ssl_access_log trueip_combined
LogLevel warn

SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW

SSLCertificateFile /etc/pki/tls/certs/wildcard_mydomain.com.crt
SSLCertificateKeyFile /etc/pki/tls/private/wildcard_mydomain.com.key
SSLCACertificateFile /etc/pki/tls/certs/wildcard_bundle_mydomain.com.ca-bundle

<Files ~ "\.(cgi|shtml|phtml|php3?)$">
    SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
    SSLOptions +StdEnvVars
</Directory>

SetEnvIf User-Agent ".*MSIE.*" \
         nokeepalive ssl-unclean-shutdown \
         downgrade-1.0 force-response-1.0

CustomLog logs/ssl_request_log \
          "%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \"%r\" %b"
</VirtualHost>

这样,如果我输入https://ip_server我查看网站,有办法查看网站只是调用主机名(my.domain.com)?

1 个答案:

答案 0 :(得分:0)

我在域虚拟主机之前用这些行解决了:

<VirtualHost *:443>
    ServerName catchall
    DocumentRoot "/var/www/html"
    SSLEngine on
    SSLProtocol all -SSLv2
    SSLCipherSuite ALL:!ADH:!EXPORT:!SSLv2:RC4+RSA:+HIGH:+MEDIUM:+LOW
    SSLCertificateFile /etc/pki/tls/certs/wildcard_mydomain.com.crt
    SSLCertificateKeyFile /etc/pki/tls/private/wildcard_mydomain.com.key
    SSLCACertificateFile /etc/pki/tls/certs/wildcard_bundle_mydomain.com.ca-bundle
</VirtualHost>