centos-搭建https服务器
来源:互联网 发布:汇量科技 知乎 编辑:程序博客网 时间:2024/06/15 17:37
一、需要先搭建好http服务器。
http://blog.csdn.net/u010029439/article/details/78395364
二、https服务器搭建。
1.我理解的https。
度娘写的很好。
https协议的作用是,建立安全稳定的通讯连接。服务器和客户端通过握手,来创建加密数据流通信。
2.一个很有趣的事情:
所有支持https协议的网址,地址栏前面都会显示个锁。点击锁,会出现所有的认证信息。
如果服务器的加密ca没有被正式的ca机构认证,当我们用浏览器访问它时,会弹出危险提示。
3搭建。
更好的解释是给appache加入ssl协议支持。
http://blog.csdn.net/huaishuming/article/details/44080643
1)先按装mod_ssl
yum install mod_ssl
完毕后在
/etc/httpd/conf.d/下会有一个ssl.conf的文件,打开
主要是看下证书及密钥的位置
SSLCertificateFile /etc/pki/tls/certs/localhost.crt
SSLCertificateKeyFile /etc/pki/tls/private/localhost.key
(2)生成密钥,
进入/etc/pki/tls/private,
删除原来的localhost.key
rm -f localhost.key
生成新的localhost.key:
openssl genrsa 1024 > localhost.key
返回到certs目录
cd ../certs
删除原来的证书
rm -rf localhost.crt
生成新的
openssl req -new -x509 -days 365 -key ../private/localhost.key -out localhost.crt
填写需要填写的信息,证书就生成了
这里为什么要用localhost.crt这样的名子,是因为在ssl.conf就是这样子指定的,这两个地方要一样。
重启apache,配置结束
现在就可以通过https访问网站
可能需要开发端口443号:iptables -I INPUT -p TCP –dport 443 -j ACCEPT
个人以为,到这里就足够了,我的电脑端口号也不需要开发,就可以访问了。
Apache下设置自动将http跳转到https方法
启用了https的ssl证书,现在需要将原先的http直接跳转到https上,下面我给出我经常使用的方法,利用伪静态功能
首先在网站根目录下创建.htaccess文件,如果目录下已经有.htaccess文件,则用vi或者其他编辑器打开,在最下面添加写入如下语句即可
RewriteEngine on RewriteBase / RewriteCond %{SERVER_PORT} !^443$ RewriteRule ^.*$ https://%{SERVER_NAME}%{REQUEST_URI} [L,R]
apache的虚拟主机配置
1、在httpd.conf中打开vhosts和ssl的配置文件
# vi /usr/local/apache/conf/httpd.conf
打开vhosts配置
跳转到447行和459行
取消掉Include conf/extra/httpd-vhosts.conf和Include conf/extra/httpd-ssl.conf之前的注释
2、配置vhosts
# vi /usr/local/apache/conf/extra/httpd-vhosts.conf
特别需要注意443段的配置,可在httpd-ssl.conf中找到相关说明
[php] view plain copyNameVirtualHost *:80 NameVirtualHost *:443 DocumentRoot "/data/www/" ServerName 192.168.1.201 Order allow,deny Allow from all Options -Indexes FollowSymLinks AllowOverride All DocumentRoot "/data/www/" ServerName 192.168.1.201:443 SSLEngine on SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL SSLCertificateFile "/usr/local/apache/conf/ssl.key/server.cert" SSLCertificateKeyFile "/usr/local/apache/conf/ssl.key/server.key" SSLOptions +StdEnvVars Order allow,deny Allow from all Options -Indexes FollowSymLinks AllowOverride All BrowserMatch ".*MSIE.*" \ nokeepalive ssl-unclean-shutdown \ downgrade-1.0 force-response-1.0
3、修改httpd-ssl.conf的相关配置
# vi /usr/local/apache/conf/extra/httpd-ssl.conf
搜索SSLCertificateFile
并将:(99行)SSLCertificateFile “/usr/local/apache/conf/server.crt”
改为:SSLCertificateFile “/usr/local/apache/conf/ssl.key/server.cert”
注:本章生成的非crt,请注意修改随后的cert
搜索SSLCertificateKeyFile
并将:(107行)SSLCertificateKeyFile “/usr/local/apache/conf/server.key”
改为:SSLCertificateKeyFile “/usr/local/apache/conf/ssl.key/server.key”
4、重启apache
# service httpd start Apache/2.2.21 mod_ssl/2.2.21 (Pass Phrase Dialog) Some of your private key files are encrypted for security reasons. In order to read them you have to provide the pass phrases. Server www.example.com:443 (RSA) Enter pass phrase: OK: Pass Phrase Dialog successful.
- centos-搭建https服务器
- centos tomcat 搭建https 服务器
- centos下使用nginx搭建https服务器
- centos下使用nginx搭建https服务器
- centos使用nginx搭建https服务器
- Centos下搭建 tomcat https服务器详解(原创)
- Centos Nginx搭建https
- Nginx搭建HTTPS服务器
- nginx搭建https服务器
- Nginx 搭建 HTTPS 服务器
- nginx搭建https服务器
- nginx搭建https服务器
- Nginx搭建HTTPS服务器
- 搭建https服务器
- Nginx搭建https服务器
- Node 搭建https服务器
- nginx 搭建https服务器
- nginx搭建https服务器
- Unity Shader 学习笔记(9) 渐变纹理、遮罩纹理
- android 执行monkey指令的方法
- 定义一个圆形类,实现圆的的面积计算
- api设计干货
- (二)Git的安装与配置
- centos-搭建https服务器
- Linux基本指令、文件管理权限及Linux重要目录的整理
- Mac使用 matplotlib 画图 => RuntimeError: Python is not installed as a framework
- tomcat虚拟路径——webapps目录外部静态资源访问
- 特殊体系的相平衡和精馏模拟计算.pdf
- ArcGIS Pro2.0利用 Import 3D Files 工具支持主流的三维模型导入
- SQL注入神器-sqlmap
- jdbc加载驱动
- 【特征检测】HOG特征算法