Linux服务之nginx服务篇四(配置https协议访问)
一、配置nginx支持https协议访问
编译安装nginx的时候需要添加相应的模块--with-http_ssl_module和--with-http_gzip_static_module(可通过/usr/local/nginx/sbin/nginx -V来查看nginx编译参数)
(yum安装不需要)
二、防火墙开启https协议默认端口443
1、vi /etc/sysconfig/iptables #编辑防火墙配置文件,添加以下代码:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
:wq! #保存退出
service iptables restart #重启防火墙
2、或者使用firewall-cmd添加防火墙规则
firewall-cmd --add-port=443/tcp
firewall-cmd --add-port=443/tcp --permanent
三、创建https证书
确保机器上安装了OpenSSL和openssl-devel
yum install openssl openssl-devel #CentOS使用yum命令安装
mkdir /etc/nginx/ssl #创建证书存放目录
cd /etc/nginx/ssl #进入目录 创建服务器私钥:
openssl genrsa -des3 -out server.key 1024 #根据提示输入证书口令(ryz123) 创建签名请求的证书(CSR):
openssl req -new -key server.key -out server.csr #输入上面设置的口令(ryz123)
#根据提示输入相应的信息
Country Name (2 letter code) [XX]:cn #国家
State or Province Name (full name) []:shanxi #省份
Locality Name (eg, city) [Default City]:taiyuan #城市
Organization Name (eg, company) [Default Company Ltd]:3344 #公司
Organizational Unit Name (eg, section) []:yunwei #部门
Common Name (eg, your name or your server's hostname) []:3344 #主机名称
Email Address []:[email protected] #邮箱
Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:123456 #证书请求密钥,CA读取证书的时候需要输入密码
An optional company name []:3344 #公司名称,CA读取证书的时候需要输入密码 openssl rsa -in server.key -out server_nopassword.key #对key进行解密
openssl x509 -req -days 365 -in server.csr -signkey server_nopassword.key -out server.crt #标记证书使用上述私钥(ryz123)和CSR [root@s2 ssl]# ls
server.crt server.csr server.key server_nopassword.key
[root@s2 ssl]# pwd
/etc/nginx/ssl
四、修改nginx的配置文件,网站添加安全验证(https)
server {
listen 80;
server_name www.3344.com;
location / {
rewrite ^(.*)$ https://$host$1 permanent; #把http协议重定向到https上面
}
}
server {
listen 443 ssl;
server_name www.3344.com;
ssl_certificate "/etc/nginx/ssl/server.crt";
ssl_certificate_key "/etc/nginx/ssl/server_nopassword.key";
fastcgi_param HTTPS $https if_not_empty; #有https协议时自动使用https,否则忽略这个参数。
root /var/www/html;
}
Linux下nginx配置https协议访问如上。
Linux服务之nginx服务篇四(配置https协议访问)的更多相关文章
- 【转】Linux下nginx配置https协议访问的方法
一.配置nginx支持https协议访问,需要在编译安装nginx的时候添加相应的模块--with-http_ssl_module 查看nginx编译参数:/usr/local/nginx/sbin/ ...
- Tomcat配置https协议访问
Tomcat9配置https协议访问: https://blog.csdn.net/weixin_42273374/article/details/81010203 配置Tomcat使用https协议 ...
- Linux下nginx配置https协议访问
一.配置nginx支持https协议访问,需要在编译安装nginx的时候添加相应的模块--with-http_ssl_module 查看nginx编译参数:/usr/local/nginx/sbin/ ...
- Linux下nginx配置https协议访问的方法
一.配置nginx支持https协议访问,需要在编译安装nginx的时候添加相应的模块--with-http_ssl_module 查看nginx编译参数:/usr/local/nginx/sbin/ ...
- nginx反向代理批量实现https协议访问
我们进入大多数HTTPS网站ie浏览器都会给出相关提醒了,但我配置了一台HTTPS代理机器发现css与js都加载不了,这个有朋友说是https页面,如果加载http协议的内容,会被认为页面不安全,所以 ...
- 【netcore基础】CentOS 7.6.1810 搭建.net core 2.1 linux 运行环境 nginx反向代理 supervisor配置自启动
之前写过一篇Ubuntu的环境搭建博客,感觉一些配置大同小异,这里重点记录下 nginx 作为静态 angular 项目文件服务器的配置 参考链接 [netcore基础]ubuntu 16.04 搭建 ...
- 在linux下的apache配置https协议,开启ssl连接
环境:linux 配置https协议,需要2大步骤: 一.生成服务器证书 1.安装openssl软件 yum install -y openssl mod_ssl 2.生成服务器私匙,生成server ...
- 使用nginx代理后以及配置https后,如何获取真实的ip地址
使用nginx代理后以及配置https后,如何获取真实的ip地址 Date:2018-8-27 14:15:51 使用nginx, apache等反向代理后,如果想获取请求的真实ip,要在nginx中 ...
- nginx证书制作以及配置https并设置访问http自动跳转https(反向代理转发jboss)
nginx证书制作以及配置https并设置访问http自动跳转https 默认情况下ssl模块并未被安装,如果要使用该模块则需要在编译时指定–with-http_ssl_module参数,安装模块依赖 ...
随机推荐
- java正则匹配${xxx} 排除单引号双引号内的内容,前提引号必须成对出现
public static void main(String[] a) { String wpp = "select 1, ${mark} '``this is, `/message22` ...
- 跨域库herryPostMessage.js的一些优化,多iframe跨域
旧库见文章:https://www.cnblogs.com/wuhairui/p/14595893.html 新版库主要做了下多个iframe和父页面交互的优化.主要使用构造函数的方式将多个ifram ...
- 安装maven工程报错"Failed to execute goal on project...Could not resolve dependencies for project..."
我在qingcheng_interface中Lifecycle目录下执行install命令后报错"Failed to execute goal on project...Could not ...
- 20 行简单实现一个 unstated-next 🎅
前言 unstated-next 基于 React 心智模型(hook+context)而设计的状态管理. 在 react hook 出现之前,有基于单一数据源,使用纯函数修改状态的 redux &a ...
- pytorch从入门到放弃(目录)
目录 前置基础 Pytorch从入门到放弃 推荐阅读 前置基础 Python从入门到放弃(目录) 人工智能(目录) Pytorch从入门到放弃 01_pytorch和tensorflow的区别 02_ ...
- 刨死你系列——手撕ArrayList
不多BB,直接上代码: public class MyArrayList { //创建数组对象 private Object[] elements; //已使用数组长度 private int siz ...
- 实时计算框架:Spark集群搭建与入门案例
一.Spark概述 1.Spark简介 Spark是专为大规模数据处理而设计的,基于内存快速通用,可扩展的集群计算引擎,实现了高效的DAG执行引擎,可以通过基于内存来高效处理数据流,运算速度相比于Ma ...
- Jenkins 自动触发执行的配置
1. 两种触发方式 2. jenkins 和 github 同步配置 ngrok 安装 webhook 配置 1. 两种触发条件 Jenkins 中建立的任务是可以设置自动触发,更进一步的实现自动化. ...
- 记一次xss漏洞挖掘
博客园在整改中,无法更新文章,难受啊... 记录一次react的xss漏洞发现,比较有意思: 某个站: 直接输入<xxx>,直接把我跳转到了404,猜测可能做了一些验证: 尝试多重编码,发 ...
- 模拟退火算法Python编程(3)整数规划问题
1.整数规划问题 整数规划问题在工业.经济.国防.医疗等各行各业应用十分广泛,是指规划中的变量(全部或部分)限制为整数,属于离散优化问题(Discrete Optimization). 线性规划问题的 ...