示例

worker_processes 1;

events {
worker_connections 1024;
} http {
#均衡负载
upstream demo{
server localhost:55328;
server localhost:55329;
} include mime.types;
default_type application/octet-stream; sendfile on;
#保持连接时间
keepalive_timeout 65;
#允许请求最大数据量
client_max_body_size 500m;
map $http_upgrade $connection_upgrade {
default upgrade;
}
#访问80端口,重定向到https
server {
listen 80;
server_name [server_name];
rewrite ^(.*)$ https://${server_name}$1 permanent;
} server {
listen 443 ssl;
server_name [server_name]; #ssl_certificate ./ssl/[server_name].pem; # 指定证书的位置,Linux上可以设置相对路径,Windows上要设置绝对路径
#ssl_certificate_key ./ssl/[server_name].key; # 同上
#ssl_trusted_certificate ./ssl/[server_name].cer; ssl_certificate ./ssl/fullchain.cer;
ssl_certificate_key ./ssl/[server_name].key; ssl_session_timeout 5m;
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; #按照这个协议配置
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;#按照这个套件配置
ssl_prefer_server_ciphers on; proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme; location / {
proxy_connect_timeout 1;
proxy_pass http://demo;
}
location /NotiHub {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://demo/NotiHub;
}
location /TaskLogHub {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://demo/TaskLogHub;
}
location = /50x.html {
root html;
}
error_page 404 500 502 503 504 /50x.html;
}
}

配置说明

#转发Tcp
stream {
proxy_timeout 30m;
server {
listen 8080;
proxy_pass localhost:55328;
}
}
#使用 WebSocket 需要添加以下配置
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
#使用 SSE 需要添加以下配置
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1; proxy_set_header Connection;
chunked_transfer_encoding off;
proxy_cache off;

Nginx配置https以及配置说明的更多相关文章

  1. Nginx配置Https

    1.申请证书: https://console.qcloud.com/ssl?utm_source=yingyongbao&utm_medium=ssl&utm_campaign=qc ...

  2. 【转】Linux下nginx配置https协议访问的方法

    一.配置nginx支持https协议访问,需要在编译安装nginx的时候添加相应的模块--with-http_ssl_module 查看nginx编译参数:/usr/local/nginx/sbin/ ...

  3. nginx配置https双向验证(ca机构证书+自签证书)

    nginx配置https双向验证 服务端验证(ca机构证书) 客户端验证(服务器自签证书) 本文用的阿里云签发的免费证书实验,下载nginx安装ssl,文件夹有两个文件 这两个文件用于做服务器http ...

  4. Nginx 配置https 服务

    一.HTTPS 服务 为什么需要HTTPS? 原因:HTTP不安全 1.传输数据被中间人盗用.信息泄露 2.数据内容劫持.篡改 HTTPS协议的实现 对传输内容进行加密以及身份验证 HTTPS加密校验 ...

  5. nginx配置https转发到tomcat(使用自签名的证书)

    一.使用openSSL生成自签名的证书 1.生成RSA私钥 命令:openssl genrsa -des3 -out server.key 1024 说明:生成rsa私钥,des3算法,1024强度, ...

  6. RedHat 6.6下安装nginx,配置HTTPS

    1.安装依赖包 yum -y install pcre-devel openssl-devel zlib-devel 2.下载nginx安装包到服务器上,当前使用版本nginx-1.15.5.tar. ...

  7. nginx 配置https并自签名证书

    2016-10-28 转载请注明出处:http://daodaoliang.com/ 作者: daodaoliang 版本: V1.0.1 邮箱: daodaoliang@yeah.net 参考链接: ...

  8. [记录]NGINX配置HTTPS性能优化方案一则

    NGINX配置HTTPS性能优化方案一则: 1)HSTS的合理使用 2)会话恢复的合理使用 3)Ocsp stapling的合理使用 4)TLS协议的合理配置 5)False Start的合理使用 6 ...

  9. 购买https证书以及nginx配置https

    文章来源 运维公会:购买https证书以及nginx配置https 1.https的作用 https的全名是安全超文本传输协议,是在http的基础上增加了ssl加密协议.在信息传输的过程中,信息有可能 ...

随机推荐

  1. SQL Server双机热备之发布、订阅实现实时同步

    一.复制的功能概述 SQL Server 复制功能实现了主从库的分离,从而将主库的压力分解掉,主库就主要负责数据的更改等,而主库主要负责查询ji.另外,有了主.从库,则从另一个方面,也了一层安全性,即 ...

  2. Django项目打分系统

    Django项目之个人网站 关注公众号"轻松学编程"了解更多. Github地址:https://github.com/liangdongchang/MyWeb.git 感兴趣的可 ...

  3. 烧录时发生:permission denied:'/dev/ttyUSB0'问题的解决

    在执行make flash的过程中出现错误: 解决办法: sudo chmod -R 777 /dev/ttyUSB0 这种设置在下次使用的,又会出现这种问题,还要重新设置 永久性的设置可以使用下面这 ...

  4. kali中PHANTOM-EVASION 3.0运行时module ' OpenSSL.crypto' has no attribute ' PKCS12Type'报错解决方法

    kali中直接用pip install pyopenssl安装当最新的openssl中的crypto中的类PKCS12Type改成了PKCS12 所以需要在phantom中改对应代码 将这个文件中对应 ...

  5. 它是世界上最好的语言,吊打PHP那种

    Scratch Scratch是麻省理工媒体实验室终身幼稚园组开发的一套电脑程序开发平台,旨在让程序设计语言初学者不需先学习语言语法便能设计产品.开发者期望通过学习Scratch,启发和激励用户在愉快 ...

  6. javascript中什么是函数

    函数的定义 在javascript中函数是一段可以被执行或调用任意次数的JavasScript代码,在数据类型中属于"function".函数也拥有属性和方法,因此函数也是对象. ...

  7. 主动关闭 time wait结构体

    /* * This is a TIME_WAIT sock. It works around the memory consumption * problems of sockets in such ...

  8. Python 中 'unicodeescape' codec can't decode bytes in position XXX: trun错误解决方案

    window 读取文件可以用\,但是在字符串中\是被当作转义字符来使用,'C:\Users\FrankYuan\Pictures\Camera Roll\WIN_20161010_08_51_57_P ...

  9. UNP——第二章,端口号,套接字对,TCP,UDP输出

    1.端口号 端口号用于区分使用相同协议的进程. TCP69 与 UDP69 是不同的. 端口号范围 0 - 65535, 其中 0- 1023 是保留端口. 2.套接字对 TCP服务通过套接字对,唯一 ...

  10. php 与 docker php-fpm 共存问题

    需求: 本地一个 php7 的 php-fpm,现在需要运行 php5.2版本的程序, 服务器安装的 nginx 解析域名,碰见 php 文件交给 php5的 php-fpm; 注意: fastcgi ...