阿里云服务器配置https(总结)

一、总结

一句话总结:

1、下载https证书(可以在阿里云上)
2、在服务器上面开启443端口
3、配置apache服务器,443的加ssl,让80的重定向到443
4、安装mod_ssl模块:yum install mod_ssl

1、apache将http(80)链接跳转到https(443)?

RewriteCond配合RewriteRule来跳转:RewriteRule ^(.*)?$ https://%{SERVER_NAME}$1 [L,R]
<VirtualHost *:>
RewriteEngine on
RewriteCond %{SERVER_PORT} !^$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}$1 [L,R]
ServerName www.fanrenyi.com
ServerAlias fanrenyi.com
</VirtualHost>

2、阿里云上配置apache启示?

可以多参照阿里云上面提供的手册:阿里云https证书服务那里下载证书那里有怎么教你详细的做

3、https的端口号是多少?

443

二、阿里云服务器配置https

1、在阿里云上面下载https证书

具体怎么做可以参考以下网址或者百度

学会在阿里云申请免费SSL证书,从而把网站变为HTTPS访问-云栖社区-阿里云
https://yq.aliyun.com/articles/720759?spm=a2c4e.11155472.0.0.24124494m4E2Hi

2、在服务器上面开启443端口

因为443是https默认端口

3、配置apache服务器

阿里云https证书服务那里下载证书那里有怎么教你详细的做

httpd-ssl.conf成功的配置:

Listen
AddType application/x-x509-ca-cert .crt
AddType application/x-pkcs7-crl .crl
SSLPassPhraseDialog builtin
SSLSessionCache "shmcb:logs/ssl_scache(512000)"
SSLSessionCacheTimeout
SSLUseStapling On
SSLStaplingCache "shmcb:logs/ssl_stapling(512000)"
# 添加 SSL 协议支持协议,去掉不安全的协议
SSLProtocol all -SSLv2 -SSLv3
SSLProxyProtocol -All +TLSv1. +TLSv1.
# 修改加密套件如下
SSLCipherSuite HIGH:!RC4:!MD5:!aNULL:!eNULL:!NULL:!DH:!EDH:!EXP:+MEDIUM
SSLProxyCipherSuite HIGH:!aNULL:!MD5:!3DES:!CAMELLIA:!AES128
SSLHonorCipherOrder on
SSLCompression off
Mutex sysvsem default
SSLStrictSNIVHostCheck on
#公钥
SSLCertificateFile cert/--------------------------.crt
#私钥
SSLCertificateKeyFile cert/---------------------------.key
#证书链文件
SSLCertificateChainFile cert/------------------------.crt
<VirtualHost _default_:>
SSLEngine on
#ServerName localhost
ServerName fanrenyi.com:
ServerAlias www.fanrenyi.com:
DocumentRoot ---------------------------------
#DocumentRoot /data/www/default
#<Directory /data/www/default>
<Directory ----------------------------------->
SetOutputFilter DEFLATE
Options FollowSymLinks
AllowOverride All
Order Deny,Allow
Allow from All
DirectoryIndex index.php index.html index.htm
</Directory>
</VirtualHost>

4、成功的效果

5、laravel项目中自动跳转到https中

将http(80)链接跳转到https(443):

<VirtualHost *:>
RewriteEngine on
RewriteCond %{SERVER_PORT} !^$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}$1 [L,R]
ServerName www.fanrenyi.com
ServerAlias fanrenyi.com
</VirtualHost>

6、记得安装mod_ssl

如果一开始只安装了httpd,还要安装mod_ssl才能开启SSL

所以记得yum install mod_ssl

三、参考:阿里云服务器上开启HTTPS(记录趟过的各种坑)

转自或参考:阿里云服务器上开启HTTPS(记录趟过的各种坑)
https://blog.csdn.net/nuc_badaomen/article/details/80452173

 

服务器环境:phpstudy

证书:从阿里云网站申请的免费证书,具体请自行百度

重要步骤:

1.确定服务器已经开启443端口,因为443是https默认端口,如何开启自行百度

2.开启apache相应配置

#修改httpd.conf文件

LoadModule ssl_module modules/mod_ssl.so
Include conf/extra/httpd-ssl.conf
LoadModule rewrite_module
#去掉上面三行前的"#"
保存退出

3.在apache目录下的httpd目录下新建一个cert目录,将证书放到该目录下

4.确定已开启openssl模块,通过phpinfo()可以查看是否开启

5.修改httpd-ssl.conf文件如下,其余的删除即可

Listen 443
<VirtualHost *:443>
DocumentRoot "网站根目录"
ServerName 域名:443
ErrorLog logs/ssl_error_log
TransferLog logs/ssl_access_log
LogLevel warn
<Directory "网站根目录">
Options Indexes FollowSymLinks
AllowOverride All
Require all granted
</Directory>
SSLEngine on
SSLProtocol all -SSLv2
SSLCipherSuite HIGH:MEDIUM:!aNULL:!MD5:!SEED:!IDEA
[plain] view plain copy
#公钥
SSLCertificateFile /phpstudy/server/httpd/cert/public.pem
[plain] view plain copy
#私钥
SSLCertificateKeyFile /phpstudy/server/httpd/cert/xxxxxx.key
[plain] view plain copy
#证书链文件
SSLCertificateChainFile /phpstudy/server/httpd/cert/chain.pem <Files ~ "\.(cgi|shtml|phtml|php3?)$">
SSLOptions +StdEnvVars
</Files>
<Directory "/var/www/cgi-bin">
SSLOptions +StdEnvVars
</Directory>
BrowserMatch "MSIE [2-5]" \
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>

6.重启apache即可,如不能正常启动请从第一步开始检查,是否每一步都正确

 
 

四、参考:apache2.4配置https

转自或参考:apache2.4配置https
https://www.cnblogs.com/jie-hu/p/8034226.html

1、获取证书

1.1 openssl生成SSL证书(自行百度)

1.2 腾讯云,阿里云,百度云等等都有提供免费的SSL证书

2、证书安装

编辑Apache根目录下 conf/httpd.conf 文件,找到#LoadModule ssl_module/mod_ssl.so 和 #Include conf/extra/httpd-ssl.conf,去掉前面的#号注释;

编辑Apache跟目录下 conf/extra/httpd-ssl.conf 文件,修改如下内容:

<VirtualHost *:443>
DocumentRoot "/var/www/html"
ServerName www.domain.com:443
SSLEngine on
SSLCertificateFile /usr/local/apache/conf/2_www.domain.com_cert.crt
SSLCertificateKeyFile /usr/local/apache/conf/3_www.domain.com.key
SSLCertificateChainFile /usr/local/apache/conf/1_root_bundle.crt
</VirtualHost>


配置完成后,重新启动 Apache 就可以使用https://www.domain.com来访问了。
注:

配置文件参数 说明
SSLEngine on 启用SSL功能
SSLCertificateFile 证书文件
SSLCertificateKeyFile 私钥文件
SSLCertificateChainFile

证书链文件

3、apache配置重定向

在.htaccess文件中加入如下代码:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>

在.htaccess文件中加入如ps:如果项目使用了.htaccess隐藏了index.php(例如tp3.2),可在.htaccess文件中加入如下代码:

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{SERVER_NAME}/$1 [R,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . index.php
</IfModule>

也可以利用php做https的跳转:

<?php if ($_SERVER["HTTPS"] <> "on")
{
$xredir="https://".$_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"]; header("Location: ".$xredir);
}
?>

然后伪静态就正常去掉index.php功能:

<IfModule mod_rewrite.c>
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php [L,E=PATH_INFO:$1]
</IfModule>

配置完成后,http就可以重定向到https了。

4、遇到的问题

4.1 外网443端口被防火墙关闭

4.2 在windows Server 2012服务器上配置httpd-ssl.conf时VirtualHost *:443 * 号使用域名出错,这里建议用*/ip

阿里云服务器配置https(总结)的更多相关文章

  1. 阿里云服务器配置https(port443)后客户端 svn check out 失效解决办法

    1. 客户端环境 1. 操作系统:Windows 7 2. svn客户端:TortoiseSVN 2. 服务端环境 1. 云服务平台:阿里云 2. 操作系统:Windows Server 2008 R ...

  2. 阿里云服务器配置https

    第一步 在阿里云控制台找到申请ssl证书的地址(我申请的是阿里云免费的证书,申请完要等申请通过,可能要等待一两天) 第二步下载ssl nginx版本的证书 第三步上传证书(包含.key, .pem这两 ...

  3. 项目总结20:阿里云免费https证书申请

    项目总结20:阿里云免费https证书申请 1. 登录阿里云控制台 www.aliyun.com,用账户信息登录 2. 在”产品与服务”搜索SSL,选择SSL证书 3. 点击购买证书 4. 选择” S ...

  4. 阿里云配置HTTPS

    阿里云配置HTTPS 2018-05-29 16:00:56 by SemiconductorKING 最近申请域名配置了一下HTTPS协议,记录一下配置过程. 准备 备案过的域名,一个SSL证书(免 ...

  5. 阿里云服务器配置SSL证书成功开启Https(记录趟过的各种坑)

    环境: 阿里云云服务器    Windows Server 2008 标准版 SP2 中文版(趁1212优惠买的一年的水货配置) 阿里云购买的域名(已备案.已解析) 服务器:phpstudy:php5 ...

  6. 阿里云服务器配置免费https服务

    过程总述 购买服务器,购买域名,备案 申请ssl证书 DNS验证 上传证书,配置nginx 很关键,打开端口!!!阿里云的443端口默认是不打开的 1.购买服务器,域名,备案 服务器我是买的阿里云的, ...

  7. 在阿里云域名https配置(nginx为例)

    如题: 在阿里云上注册了域名之后在阿里云域名控制台配置https: 1.在域名控制台选择要配置的域名,并在操作栏点击“解析” 2.在域名解析点击更多下的SSL进入到证书列表页,这里有收费的也有免费的, ...

  8. 阿里云配置 https 证书

    阿里云配置中心 https://yundun.console.aliyun.com/?p=cas#/cas/home 证书审核通过后复制到 ecs scp /path/filename usernam ...

  9. 微信小程序阿里云服务器https搭建

    已更新 2018-11-20 1.什么是https?HTTPS(全称:安全套接字层上的超文本传输​​协议),是以安全为目标的HTTP通道,简单讲是HTTP的安全版.即HTTP下加入SSL层,HTTPS ...

随机推荐

  1. Shiro安全框架入门使用方法

    详见:https://blog.csdn.net/qq_32651225/article/details/77199464 框架介绍Apache Shiro是一个强大且易用的Java安全框架,执行身份 ...

  2. C#为什么要装箱和拆箱

    来自论坛4楼的回答非常棒,地址:https://bbs.csdn.net/topics/390624164?page=1 内容如下: 道理很简单,按理说C#被设计成一种完全面向对象的语言.因此,包括数 ...

  3. cuda实现向量相加

    cuda实现向量相加 博客最后附上整体代码 如果有说的不对的地方还请前辈指出, 因为cuda真的接触没几天 一些总结(建议看) cuda 并不纯GPU在运行程序, 而是 cpu 与 gpu 一起在运行 ...

  4. Spring 的 @Primary 注解

    简单的说,就是当Spring容器扫描到某个接口的多个 bean 时,如果某个bean上加了@Primary 注解 ,则这个bean会被优先选用,如下面的例子: @Component public cl ...

  5. Java关键字—final

    final—不可变的,用来说明最终属性,表明一个类不能派生出子类,或者成员方法不能被覆盖,或者成员域的值不能被改变. 修饰范围: 1.修饰类,被final关键字修饰的类无法被继承: 2.修饰方法,被f ...

  6. Nginx基本参数调优

    Nginx基本参数 #运行用户 user nobody; #worker进程的个数:通常应该为物理CPU核数减1: #可以为”auto”,实现自动设定(worker_processes  auto) ...

  7. linux网络编程之posix线程(一)

    今天继续学习posix IPC相关的东东,消息队列和共享内存已经学习过,接下来学习线程相关的知识,下面开始: [注意]:创建失败这时会返回错误码,而通常函数创建失败都会返回-1,然后错误码会保存在er ...

  8. 在angular项目中使用web-component ----How to use Web Components with Angular

    原文: https://medium.com/@jorgecasar/how-to-use-web-components-with-angular-41412f0bced8 ------------- ...

  9. SQL SERVER表压缩

    概述 SQL Server的主要性能取决于磁盘I/O效率,SQL Server .2008提供了数据压缩功能来提高磁盘I/O效率.表压缩意味着减小数据的磁盘占有量,所以压缩可以用在堆表.聚集索引的表. ...

  10. LeetCode 339. Nested List Weight Sum

    原题链接在这里:https://leetcode.com/problems/nested-list-weight-sum/ 题目: Given a nested list of integers, r ...