Nginx 配置 HTTPS SSL
配置文件如下:【可以在阿里云上申请免费证书】
#user nobody;
worker_processes 1; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'; sendfile on; keepalive_timeout 65; server {
# HTTPS 默认443端口
listen 443 ssl;
# 证书文件配置,指定证书的路径,除了证书路径其他配置都默认
ssl_certificate /usr/local/nginx/ssl/server.crt;
ssl_certificate_key /usr/local/nginx/ssl/server.key;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
ssl_ciphers HIGH:!aNULL:!MD5:!DH; # host
server_name example.com www.example.com; #设置长连接
keepalive_timeout 70;
#减少点击劫持
add_header X-Frame-Options DENY;
#禁止服务器自动解析资源类型
add_header X-Content-Type-Options nosniff;
#防XSS攻击
add_header X-Xss-Protection 1; # 默认index
index index.html index.htm index.php default.html default.htm default.php;
# 代码的根目录
root /home/wwwroot/example;
# 访问日志
access_log /usr/local/nginx/logs/example.com.log main; } # 全站使用HTTPS,让通过HTTP访问的用户301跳转到HTTPS
server {
listen 80;
#server_name newhealth.com.cn www.newhealth.com.cn;
server_name example.com www.example.com;
#使用return的效率会更高
return 301 https://$server_name$request_uri;
}
}
[root@localhost sbin]# ./nginx -V
nginx version: nginx/1.12.2
built by gcc 4.8.5 20150623 (Red Hat 4.8.5-36) (GCC)
built with OpenSSL 1.0.2k-fips 26 Jan 2017
TLS SNI support enabled
configure arguments: --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module --with-stream --with-stream_ssl_preread_module --with-stream_ssl_module
[root@localhost sbin]#
Nginx 配置 HTTPS SSL的更多相关文章
- Nginx 配置 HTTPS SSL 代理
配置文件如下: #user nobody; worker_processes 1; events { worker_connections 1024; } http { include mime.ty ...
- Nginx配置Https
1.申请证书: https://console.qcloud.com/ssl?utm_source=yingyongbao&utm_medium=ssl&utm_campaign=qc ...
- 【转】Linux下nginx配置https协议访问的方法
一.配置nginx支持https协议访问,需要在编译安装nginx的时候添加相应的模块--with-http_ssl_module 查看nginx编译参数:/usr/local/nginx/sbin/ ...
- nginx配置https双向验证(ca机构证书+自签证书)
nginx配置https双向验证 服务端验证(ca机构证书) 客户端验证(服务器自签证书) 本文用的阿里云签发的免费证书实验,下载nginx安装ssl,文件夹有两个文件 这两个文件用于做服务器http ...
- Nginx 配置https 服务
一.HTTPS 服务 为什么需要HTTPS? 原因:HTTP不安全 1.传输数据被中间人盗用.信息泄露 2.数据内容劫持.篡改 HTTPS协议的实现 对传输内容进行加密以及身份验证 HTTPS加密校验 ...
- nginx配置https转发到tomcat(使用自签名的证书)
一.使用openSSL生成自签名的证书 1.生成RSA私钥 命令:openssl genrsa -des3 -out server.key 1024 说明:生成rsa私钥,des3算法,1024强度, ...
- RedHat 6.6下安装nginx,配置HTTPS
1.安装依赖包 yum -y install pcre-devel openssl-devel zlib-devel 2.下载nginx安装包到服务器上,当前使用版本nginx-1.15.5.tar. ...
- nginx 配置https并自签名证书
2016-10-28 转载请注明出处:http://daodaoliang.com/ 作者: daodaoliang 版本: V1.0.1 邮箱: daodaoliang@yeah.net 参考链接: ...
- [记录]NGINX配置HTTPS性能优化方案一则
NGINX配置HTTPS性能优化方案一则: 1)HSTS的合理使用 2)会话恢复的合理使用 3)Ocsp stapling的合理使用 4)TLS协议的合理配置 5)False Start的合理使用 6 ...
随机推荐
- XAMPP + PhpStorm + Xdebug本地实验环境搭建
参考: 下载合适的XDebug 点击这里,选择合适xdebug XAMPP配置 php_xdebug-xxxx.dll 拷贝dll至 D:\XAMPP\php\ext php.ini 文末追加 [XD ...
- linux命令提示符上色
vi /etc/profile RED='\[\e[31;1m\]' Yello='\[\e[33;1m\]' Green='\[\e[32;1m\]' End='\[\e[0m\]' Pur='\[ ...
- Xenia and Weights(Codeforces Round #197 (Div. 2)+DP)
题目链接 传送门 思路 \(dp[i][j][k]\)表示第\(i\)次操作放\(j\)后与另一堆的重量差为\(k\)是否存在. 代码实现如下 #include <set> #includ ...
- rs485一主多从的连接方式及通信注意事项
rs485的通信方式看似比较简单,其实通信软件的处理还是有需要注意的. 下图是主机向从机发送信息的示意图,其中485的线都是手牵手相连的,因此主机向下发的时候,其实各个从机都有在接收数据的,只是,从机 ...
- DockerToolbox安装docker - Windows 10家庭版
由于本机使用的是win10家庭版操作系统,无法直接Docker for Windows安装,因此只好使用Docker Toolbox.在此记录一下过程,以供参考. 下载 因为toolbox安装包的官网 ...
- SUID提权
查看tmp目录权限 ll -d /tmp 切换到tmp目录 cd /tmp 创建一个exploit目录 mkdir exploit 查看ping命令带suid权限 ll /bin/ping 创建tar ...
- Windows 2008R2 安装PostgreSQL 11.6
前些天在CentOS 7.5 下安装了PostgreSQL 11.6.除了在无外网环境下需要另外配置之外,其他没有什么差别.今天主要写一下在Windows下面安装PostgreSQL的问题. 在官网看 ...
- 洛谷 UVA12101 Prime Path 题解
一道经典的BFS 用四个for搜索四位就行了,只要能推出怎么只变4位中的一位就很水了 #include<iostream> #include<cstring> #include ...
- HTML Meta标签和link标签
一.meta 标签 name属性主要用于描述网页,对应于content(网页内容) 1.<meta name="Generator" contect="" ...
- SIGIR2018 Paper Abstract Reading Notes (1)
1.A Click Sequence Model for Web Search(日志分析) 更好的理解用户行为对于推动信息检索系统来说是非常重要的.已有的研究工作仅仅关注于建模和预测一次交互行为,例如 ...