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配置的更多相关文章

  1. StartCom 申请 SSL 证书及 Nginx HTTPS 支持配置全攻略

    来源:https://www.williamyao.com/index.php/archives/1397/ 前言 最近收到 StartCom 的邮件,数字证书即将过期,想到去年在 StartSSL ...

  2. nginx多server配置记录

    直接在配置文件(/etc/nginx/nginx.conf)中添加如下代码: server { listen 8080; server_name 192.168.100.174:8080; root ...

  3. nginx https ssl 配置

    #设置https 访问server { listen ; server_name www.xxx.com; access_log xxx/xxx/xxx.log combined; index ind ...

  4. nginx下面server配置

    haomeiv配置 log_format www.haomeiv.com '$remote_addr - $remote_user [$time_local] "$request" ...

  5. Nginx, HTTPS的配置

    server {listen 443;      ####HTTPS指定端口server_name www.web.com;      #####域名或者IP root /data/wwwroot/l ...

  6. Nginx一个server配置多个location(使用alias)

    公司测试环境使用nginx部署多个前端项目.网上查到了两个办法: 在配置文件中增加多个location,每个location对应一个项目比如使用80端口,location / 访问官网: locati ...

  7. Nginx同server配置下配置多个localhost路由地址

    nginx多页面路由配置,进入 nginx/conf/nginx.conf: http { ...... server { listen 80; server_name localhost; loca ...

  8. nginx https证书配置

    1. Nginx配置 server { listen 443; #指定ssl监听端口 server_name www.example.com; ssl on; #开启ssl支持 ssl_certifi ...

  9. Nginx一个server配置多个location

    在配置文件中增加多个location,每个location对应一个项目 比如使用8066端口,location / 访问官网: location /demo访问培训管理系统配置多个站点我选择了配置多个 ...

随机推荐

  1. LeetCode—-Sort List

    LeetCode--Sort List Question Sort a linked list in O(n log n) time using constant space complexity. ...

  2. java.lang.IllegalArgumentException异常处理的一种方法

    我遇到的问题 用spring注解来加载bean,都是一个简单的了,但是还是报了这样一个错java.lang.IllegalArgumentException 网上查了一下,说是jdk版本要1.7的,然 ...

  3. C语言结构体初始化的三种方法

    直接上示例了 ? 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 3 ...

  4. 平滑重启php

    kill -USR2 `cat /usr/local/webserver/php/var/run/php-fpm.pid`

  5. 从reduce函数说起...

    reduce函数:  方法接收一个函数作为累加器(accumulator),数组中的每个值(从左到右)开始缩减,最终为一个值, 最终返回的要看函数内部return的内容. 1. 累加器: var ar ...

  6. Hibernate -- 映射多对多双向关联关系

    1. 示例代码: Student.java package cn.itcast.many2many; import java.util.HashSet; import java.util.Set; @ ...

  7. js 小复习1

    1.数组 增删改查 , , , , ]; // arr.push(18); // 添加数组后面 更改长度 // arr.unshift(12); // 添加数组前面 // arr.pop(); // ...

  8. Python globals() locals() vars() 三个内建函数的区别

    首先参考官方文档对这三个函数的介绍: 2. Built-in Functions – Python3.5 1.globals() 返回当前全局符号表, 通常是返回当前模块下的全局符号表, 比如全局内建 ...

  9. 转:大数据时代快速SQL引擎-Impala

    本文来自:http://blog.csdn.net/yu616568/article/details/52431835 如有侵权 可立即删除 背景 随着大数据时代的到来,Hadoop在过去几年以接近统 ...

  10. QT Designer 的汉化

    Designer是很好用的设计器,通过 pip 安装PyQt5之后,一般都是英文的 所以给有需要的人带来汉化的包(这个是通过替换  translations 文件夹来实现的) translations ...