Nginx httpS server配置
Nginx httpS 配置
配置同时支持http和httpS协议:
server {
listen default backlog=;
#backlog:每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包的最大数目。
listen ssl;
server_name ssl.joy4you.com;
ssl_certificate /data/nginx/conf/server.crt;
ssl_certificate_key /data/nginx/conf/server_nopwd.key;
root /data/;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ .*\.(php|php5)?$ {
# try_files $uri =;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}
}
配置/data/http/使用http协议;/data/ssl/使用httpS协议:
server {
listen ;
server_name 192.168.17.16;
access_log /data/nginx/logs/php.joy4you.com.log main;
root /data/http/;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ .*\.(php|php5)?$ {
# try_files $uri =;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}
}
server {
listen ;
ssl on;
ssl_certificate /data/nginx/conf/server.crt;
ssl_certificate_key /data/nginx/conf/server_nopwd.key;
server_name 192.168.17.16;
access_log /data/nginx/logs/php.joy4you.com.log main;
root /data/ssl/;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ .*\.(php|php5)?$ {
# try_files $uri =;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}
}
把访问80端口的请求全部转发到443(https):
server {
listen ;
server_name 192.168.17.16;
rewrite ^(.*) https://$server_name$1 permanent;
}
server {
listen ;
ssl on;
ssl_certificate /data/nginx/conf/server.crt;
ssl_certificate_key /data/nginx/conf/server_nopwd.key;
server_name 192.168.17.16;
access_log /data/nginx/logs/php.joy4you.com.log main;
root /data/;
location / {
index index.php index.html index.htm;
try_files $uri $uri/ /index.php?$args;
}
location ~ .*\.(php|php5)?$ {
# try_files $uri =;
fastcgi_pass 127.0.0.1:;
fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi.conf;
}
}
使用沃通的CA证书,他们推荐的https配置:
server {
listen ;
server_name localhost;
#为一个server开启ssl支持
ssl on;
#为虚拟主机指定pem格式的证书文件
ssl_certificate /home/wangzhengyi/ssl/wangzhengyi.crt;
#为虚拟主机指定私钥文件
ssl_certificate_key /home/wangzhengyi/ssl/wangzhengyi_nopass.key;
#客户端能够重复使用存储在缓存中的会话参数时间
ssl_session_timeout 5m;
#指定使用的ssl协议
ssl_protocols TLSv1 TLSv1. TLSv1.;
#指定许可的密码描述
ssl_ciphers ALL:!ADH:!EXPORT56: -RC4+RSA:+HIGH:+MEDIUM: !EXP;
#ssl_ciphers ALL:!ADH:!EXPORT56: -RC4+RSA:+HIGH:+MEDIUM:-EXP;
#SSLv3和TLSv1协议的服务器密码需求优先级高于客户端密码
ssl_prefer_server_ciphers on;
SLL参数:
ssl_session_timeout 5m; ##设置客户端能够反复使用储存在缓存中的会话参数时间。
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; ##指定要开启的SSL协议。
ssl_ciphers ALL:!ADH:!EXPORT56:-RC4+RSA:+HIGH:+MEDIUM:!EXP; ##指出为建立安全连接,服务器所允许的密码格式列表,密码指定为OpenSSL支持的格式
ssl_prefer_server_ciphers on; ##依赖SSLv3和TLSv1协议的服务器密码将优先于客户端密码.
Nginx httpS server配置的更多相关文章
- StartCom 申请 SSL 证书及 Nginx HTTPS 支持配置全攻略
来源:https://www.williamyao.com/index.php/archives/1397/ 前言 最近收到 StartCom 的邮件,数字证书即将过期,想到去年在 StartSSL ...
- nginx多server配置记录
直接在配置文件(/etc/nginx/nginx.conf)中添加如下代码: server { listen 8080; server_name 192.168.100.174:8080; root ...
- nginx https ssl 配置
#设置https 访问server { listen ; server_name www.xxx.com; access_log xxx/xxx/xxx.log combined; index ind ...
- nginx下面server配置
haomeiv配置 log_format www.haomeiv.com '$remote_addr - $remote_user [$time_local] "$request" ...
- Nginx, HTTPS的配置
server {listen 443; ####HTTPS指定端口server_name www.web.com; #####域名或者IP root /data/wwwroot/l ...
- Nginx一个server配置多个location(使用alias)
公司测试环境使用nginx部署多个前端项目.网上查到了两个办法: 在配置文件中增加多个location,每个location对应一个项目比如使用80端口,location / 访问官网: locati ...
- Nginx同server配置下配置多个localhost路由地址
nginx多页面路由配置,进入 nginx/conf/nginx.conf: http { ...... server { listen 80; server_name localhost; loca ...
- nginx https证书配置
1. Nginx配置 server { listen 443; #指定ssl监听端口 server_name www.example.com; ssl on; #开启ssl支持 ssl_certifi ...
- Nginx一个server配置多个location
在配置文件中增加多个location,每个location对应一个项目 比如使用8066端口,location / 访问官网: location /demo访问培训管理系统配置多个站点我选择了配置多个 ...
随机推荐
- jq限制字符个数
<script> $(document).ready(function () { //限制字符个数 $(".box-right .title a").each(func ...
- Node.Js安装教程
Node.Js安装教程 介绍下我的环境 环境 值 操作系统 win10 64bit Node.Js 8.9.4 emmmm 表格中毒了,为什么出不来效果 一.下载及安装 这个可以去Node.Js官网上 ...
- struts2自定义Interceptor拦截器
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding= ...
- GPL,BSD,Apache,MIT开源许可协议
在linux环境下学习的多了,这些开源协议也听的见的越来越多,感觉有必要仔细了解一下. 1. BSD 先说BSD是因为它的自由度相对来说是比较大的.BSD全称Berkeley Software Dis ...
- tensorflow笔记:使用tf来实现word2vec
(一) tensorflow笔记:流程,概念和简单代码注释 (二) tensorflow笔记:多层CNN代码分析 (三) tensorflow笔记:多层LSTM代码分析 (四) tensorflow笔 ...
- JSON Web Token (JWT) 简介
JSON Web Token (JWT) 是一种基于 token 的认证方案. JSON Web Token 的结构 一个 JWT token 看起来是这样的: eyJhbGciOiJIUzI1NiI ...
- Ajax-03 XmlHttpRequest实现Ajax
概述 Ajax主要就是使用XmlHttpRequest对象来完成请求的操作,该对象在主流浏览器中均存在 XmlHttpRequest对象的主要方法 a. void open(String method ...
- 更改当前启动项,开关Hyper-V
switch-HyperV.bat @echo off "%SYSTEMROOT%\system32\cacls.exe" "%SYSTEMROOT%\system32\ ...
- java JVM 随笔
先说重点: 对象在堆区 方法在栈区 变量在方法区,常量池在方法区 为什么要了解Java 虚拟机 ? 这个问题一直困惑了我很长一段时间,其实在我们开发的过程中,即使我们不了解JVM也能正常的开发,但是当 ...
- softmax实现(程序逐句讲解)
上一个博客已经讲了softmax理论部分,接下来我们就来做个实验,我们有一些手写字体图片(28*28),训练样本(train-images.idx3-ubyte里面的图像对应train-labels. ...