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. 使用VBS打开程序和关闭程序

    下面这个是先执行程序后,然后再结束程序. Dim Wsh Set Wsh = WScript.CreateObject("WScript.Shell") '下行是设置延时启动时间 ...

  2. merge two sorted lists, 合并两个有序序列

    /** * Definition for singly-linked list. * public class ListNode { * int val; * ListNode next; * Lis ...

  3. Codeforces Round #365 (Div. 2) D.Mishka and Interesting sum 树状数组+离线

    D. Mishka and Interesting sum time limit per test 3.5 seconds memory limit per test 256 megabytes in ...

  4. oracle数据库插入优化

    通过程序要把1000万的数据插入到数据表中,刚开始每100条数据耗时50ms左右,但是越往后越慢,最慢到了十几秒的都有,真实好坑了. 于是在网上百度了一波,如何进行insert优化.倒是有了一点小小的 ...

  5. 求中位数,O(n)的java实现【利用快速排序折半查找中位数】

    查找无序数组的中位数,要想时间复杂度为O(n)其实用计数排序就能很方便地实现,在此讨论使用快速排序进行定位的方法. 1.中位数定义 2.算法思想 3.Java代码实现 4.时间复杂度分析 5.附录 中 ...

  6. es6 中的let,const

    在es6中,let的作用和var差不多,都是用来声明变量的,但是他们之间的区别在于作用域不同,大家都知道在js中没有块级作用域,例如: for(var i=0;i<10;i++){ consol ...

  7. imageView图片放大缩小及旋转

    imageView图片放大缩小及旋转 一.简介 二.方法 1)设置图片放大缩小效果 第一步:将<ImageView>标签中的android:scaleType设置为"fitCen ...

  8. C++(十七) — 宏代码、内联函数

     1.C++ 表达式返回值 返回引用:当函数返回引用类型时,没有复制返回值.相反,返回的是对象本身.(与之对应的C语言中,返回的是变量的值) C++中,表达式返回的是变量本身(也就是变量对应的地址). ...

  9. docker mysql 8.0

    Pull library/mysql $ docker pull mysql Load image $ docker load -i mysql.tar Save image $ docker sav ...

  10. shell编程学习2

    1.shell中调用linux命令(1)直接执行(2)反引号括起来执行.有时候我们在shell中调用linux命令是为了得到这个命令的返回值(结果值),这时候就适合用一对反引号(键盘上ESC按键下面的 ...