前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Apache 配置https及强制使用443端口

Apache 配置https及强制使用443端口

作者头像
一朵灼灼华
发布2022-08-05 20:24:00
2.9K0
发布2022-08-05 20:24:00
举报

iptables配置443端口

代码语言:javascript
复制
vi /etc/sysconfig/iptables
代码语言:javascript
复制
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --sport 443 -j ACCEPT
代码语言:javascript
复制
service iptables restart

配置https

1.向证书机构申请https证书,会得到证书和私钥

2.安装apache的mod_ssl.so模块

代码语言:javascript
复制
yum -y install mod_ssl

3.修改 ssl.conf

代码语言:javascript
复制
vim /etc/httpd/conf.d/ssl.conf
代码语言:javascript
复制
DocumentRoot "/var/www/html"
ServerName wwww.heanny.cn:443
SSLCertificateFile /etc/pki/tls/certs/test.crt
SSLCertificateKeyFile /etc/pki/tls/private/test.key
代码语言:javascript
复制
如果是腾讯的免费证书,需要添加中间控制件
    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

4.重启httpd

代码语言:javascript
复制
sudo service httpd restart

强制443端口跳转

代码语言:javascript
复制
<Directory "/var/www/html/">
#
# Possible values for the Options directive are "None", "All",
# or any combination of:
#   Indexes Includes FollowSymLinks SymLinksifOwnerMatch ExecCGI MultiViews
#
# Note that "MultiViews" must be named *explicitly* --- "Options All"
# doesn"t give it to you.
#
# The Options directive is both complicated and important.  Please see
#  
# for more information.
#    
Options Indexes FollowSymLinks
#
# AllowOverride controls what directives may be placed in .htaccess files.
# It can be "All", "None", or any combination of the keywords:
#   Options FileInfo AuthConfig Limit
#
#改为All    
AllowOverride All
#
# Controls who can get stuff from this server.
#    
Order allow,deny    
Allow from all

#添加三行代码
RewriteEngine on
RewriteCond %{SERVER_PORT} !^443$
RewriteRule ^(.*)?$ https://%{SERVER_NAME}/$1 [L,R]
本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2018-09-05,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
SSL 证书
腾讯云 SSL 证书(SSL Certificates)为您提供 SSL 证书的申请、管理、部署等服务,为您提供一站式 HTTPS 解决方案。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档