关于apache下同IP多域名支持HTTPS和80跳转HTTPS的配置

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于apache下同IP多域名支持HTTPS和80跳转HTTPS的配置相关的知识,希望对你有一定的参考价值。

httpd-ssl的配置:

Listen 443

NameVirtualHost *:443

 

AddType application/x-x509-ca-cert .crt

AddType application/x-pkcs7-crl    .crl

 

SSLPassPhraseDialog  builtin SSLSessionCache        "shmcb:/usr/local/apache/logs/ssl_scache(512000)"

SSLSessionCacheTimeout  300

SSLMutex  "file:/usr/local/apache/logs/ssl_mutex"

 

<VirtualHost *:443>

DocumentRoot "/xxxx/Span"

ServerName resource-pov.xxx.com

SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

SSLCertificateFile "/usr/local/apache/conf/ssl/server.crt"

SSLCertificateKeyFile "/usr/local/apache/conf/ssl/server.key"

</VirtualHost>

 

<VirtualHost *:443>

DocumentRoot "/xxxx/pov.xxx.com"

ServerName pov.xxx.com

SSLEngine on

SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL

SSLCertificateFile "/usr/local/apache/conf/ssl/server.crt"

SSLCertificateKeyFile "/usr/local/apache/conf/ssl/server.key"

</VirtualHost>

 

httpd-vhosts.conf的配置:

NameVirtualHost *:80

<VirtualHost *:80>    

ServerAdmin [email protected]    

DocumentRoot "/xxxx/Span"    

ServerName  resource-pov.xxx.com    

ServerAlias resource-pov.xxx.com

<IfModule mod_rewrite.c>  

RewriteEngine On  

RewriteCond %{SERVER_PORT} 80  

RewriteRule ^(.*)$ https://resource-pov.xxx.com/$1 [R=301,L]

</IfModule>

    ErrorLog "logs/resource-pov.xxx.com-error_log"    

    CustomLog "logs/resource-pov.xxx.com-access_log" common

</VirtualHost>

 

<VirtualHost *:80>    

ServerAdmin [email protected]    

DocumentRoot "/xxxx/pov.xxx.com"    

ServerName  pov.xxx.com    

ServerAlias pov.xxx.com

<IfModule mod_rewrite.c>    //这块IfModule mod_rewrite.c是开启重定向跳转模块,将所有80的访问跳转至HTTPS,如果不想跳转可以选择去掉<IfModule mod_rewrite.c> ........ </IfModule> 这段。

RewriteEngine On  

RewriteCond %{SERVER_PORT} 80  

RewriteRule ^(.*)$ https://pov.xxx.com/$1 [R=301,L]

</IfModule>    

ErrorLog "logs/pov.xxx.com-error_log"    

CustomLog "logs/pov.xxx.com-access_log" common

</VirtualHost>


本文出自 “梦想照进现实” 博客,请务必保留此出处http://lookingdream.blog.51cto.com/5177800/1870152

以上是关于关于apache下同IP多域名支持HTTPS和80跳转HTTPS的配置的主要内容,如果未能解决你的问题,请参考以下文章

请问怎样将域名绑定到IP地址的8080端口?

#ServerName www.example.com:80CentOS 6.8下Apache绑定多个域名的方法

Apache的网站,使用Nginx进行反向代理(1个IP绑定多个域名,对应多个网站)解决方案

apache基本配置管理之:apache基于IP,port和域名三种虚拟主机配置方法

腾讯云主机安装centos,搭建apache,开启httpd服务,域名解析到公网,访问公网ip却不能访问到apache首页!

ng 能把https转发成http吗