博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Nginx httpS server配置
阅读量:4489 次
发布时间:2019-06-08

本文共 3751 字,大约阅读时间需要 12 分钟。

                                                                         Nginx httpS 配置                                                                        

 

 

配置同时支持http和httpS协议:

 

server {        listen 80 default backlog=2048;      #backlog:每个网络接口接收数据包的速率比内核处理这些包的速率快时,允许送到队列的数据包的最大数目。        listen 443 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 =404;             fastcgi_pass    127.0.0.1:9000;             fastcgi_index   index.php;#            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;             include         fastcgi.conf;}        }

 

 

配置/data/http/使用http协议;/data/ssl/使用httpS协议:

 

server {        listen       80;        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 =404;             fastcgi_pass    127.0.0.1:9000;             fastcgi_index   index.php;#            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;             include         fastcgi.conf;}}server {        listen       443;        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 =404;             fastcgi_pass    127.0.0.1:9000;             fastcgi_index   index.php;#            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;             include         fastcgi.conf;}}

 

把访问80端口的请求全部转发到443(https):
server {        listen       80;        server_name  192.168.17.16;        rewrite ^(.*) https://$server_name$1 permanent;}server {        listen       443;        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 =404;             fastcgi_pass    127.0.0.1:9000;             fastcgi_index   index.php;#            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;             include         fastcgi.conf;}}

 

 使用沃通的CA证书,他们推荐的https配置:

server { listen      443; 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.1 TLSv1.2;  #指定许可的密码描述 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协议的服务器密码将优先于客户端密码.

 

转载于:https://www.cnblogs.com/tangshengwei/p/5013341.html

你可能感兴趣的文章
Houdini 节点参数读取输入节点的数据列表
查看>>
初识Linq to Entity
查看>>
Linux vmstat命令实战详解
查看>>
FastDFS在centos上的安装配置与使用
查看>>
HDU 1709 The Balance
查看>>
2016/7/7 设置wamp2.5 mysql密码 重点是mysql版本
查看>>
简介几种负载均衡原理
查看>>
micropython logging文档
查看>>
Web站点风格切换的实现
查看>>
Python 文件操作
查看>>
免费后台管理UI界面、html源码推荐
查看>>
Topcoder SRM 656 (Div.1) 250 RandomPancakeStack - 概率+记忆化搜索
查看>>
python学习-- Django根据现有数据库,自动生成models模型文件
查看>>
github第一步之初始化操作
查看>>
《CoderXiaoban团队》第一次作业:团队亮相
查看>>
使用vue脚手架vue-cli搭建项目
查看>>
四轴飞行器Bootloader和固件的更新
查看>>
NLP之电影评分数据的情感分析
查看>>
常用网站颜色代码
查看>>
gdb使用
查看>>