本文转自:91博客;原文地址:http://www.9191boke.com/320666118.html

nginx配置ssl很简单,首先需要两个文件,一个是crt文件,另一个是key文件,如下所示:

xxx.crt;   #(证书公钥)
xxx.key;  #(证书私钥)

把这两个文件放到nginx的conf文件夹下

打开nginx配置文件,添加配置段:

nginx.conf全部内容如下:

user  nobody;
worker_processes 1; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections 1024;
} http {
include mime.types;
default_type application/octet-stream; #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #access_log logs/access.log main; sendfile on;
#tcp_nopush on; #keepalive_timeout 0;
keepalive_timeout 65; #gzip on; upstream tomcat8080_api {
server 127.0.0.1:8080 weight=1;
} server {
listen 80;
server_name huituanquan.com;
#http转https(前提是已经配置nginx ssl证书)
rewrite ^(.*)$ https://$host$1 permanent;
} # HTTPS
server {
listen 443;
server_name huituanquan.com; #网站域名 ssl on;
ssl_certificate huituanquan.com-ca-bundle.crt; #(证书公钥)
ssl_certificate_key huituanquan.com.key; #(证书私钥)

      ssl_session_timeout 5m;
      #ssl_protocols SSLv2 SSLv3 TLSv1;
      ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
      #ssl_ciphers HIGH:!aNULL:!MD5;
      ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
      ssl_prefer_server_ciphers on;

        location / {
proxy_pass http://tomcat8080_api;
proxy_redirect default;
#设置主机头和客户端真实地址,以便服务器获取客户端真实IP
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
} }

最后重启nginx即可

/alidata/server/nginx/sbin/nginx -s reload

linux下nginx配置ssl证书(https)的更多相关文章

  1. Windows下Nginx配置SSL实现Https访问(包含证书生成)

    Vincent.李   Windows下Nginx配置SSL实现Https访问(包含证书生成) Windows下Nginx配置SSL实现Https访问(包含证书生成) 首先要说明为什么要实现https ...

  2. Centos7.2下Nginx配置SSL支持https访问(站点是基于.Net Core2.0开发的WebApi)

    准备工作 1.基于nginx部署好的站点(本文站点是基于.Net Core2.0开发的WebApi,有兴趣的同学可以跳http://www.cnblogs.com/GreedyL/p/7422796. ...

  3. 【Nginx】Linux 环境下 Nginx 配置SSL 证书

    一.解压三个包到相同目录编译nginx cd /usr/local/src/nginx-1.12.2 # 将下列的包版本号换成自己下载的版本号 ./configure --prefix=/usr/lo ...

  4. Linux下Apache配置SSL支持https

    参考:http://www.thinksaas.cn/group/topic/280017/ 生成证书过程如下 Step :生成服务器密钥: mkdir -p /etc/pki/test cd /et ...

  5. Linux下Nginx配置阿里云 SSL证书实现HTTPS访问

    这篇文章主要介绍了nginx配置ssl证书实现https访问的示例 1.服务器系统:Centos 2. 阿里云申请SSL证书 选择“免费版DV SSL”,点击立即购买: 下载证书 列表中找到已签发的证 ...

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

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

  7. nginx下如何配置 ssl证书?腾讯云ssl证书为例!

    nginx下如何配置 ssl证书?腾讯云ssl证书为例! 目前为止,https已经成为一种趋势,想要开启https就需要ssl证书. 首先,为域名注册ssl证书. 腾讯云注册地址:https://cl ...

  8. Nginx - 配置 SSL证书

    nginx 配置 ssl 证书: 在nginx配置目录创建 cert目录 放置 SSL 的证书秘钥: 也可以使用配置绝对路径 /file/cert/cert.pem server { listen s ...

  9. nginx配置ssl证书的方法

    Nginx (读音"engine x") 是一个高性能的HTTP和反向代理服务器,比Apache占用更少的内存,同时也像Apache一样支持HTTPS方式访问(SSL加密).本教程 ...

随机推荐

  1. Python 连接数据库 mysql

    python 连接 数据库 import pymysql db = pymysql.connect(host='127.0.0.1',port=3306,user='root',password='r ...

  2. 【神经网络】BP反向传播神经网络

    BP算法细节 参数说明:假设有n层.J表示代价函数,和上面的E是同样的意思,只不过用不同的字母写而已. 分析:要想知道第l层的第i个结点的残差,必须知道层已经计算出来了残差,你只要把后面一层的每个结点 ...

  3. linux环境下 卸载 Oracle11G

    1.使用SQL*PLUS停止数据库 [oracle@OracleTest oracle]$ sqlplus log SQL> connect / as sysdba SQL> shutdo ...

  4. NewStyleClass学习笔记[一]

    from : https://www.python.org/doc/newstyle/ New-style Classes Unfortunately(遗憾,不幸的), new-style class ...

  5. winsock.h与winsock2.h出现重定义或不同的链接

    经常遇到编译socket程序的时候生成几百个错误 以下是出错后的错误信息: >c:\program files\microsoft sdks\windows\v6.0a\include\ws2d ...

  6. Android——用PagerAdapter实现View滑动效果

    效果: ViewPage来源于android -support.v4 什么是viewPage?ViewPage 类似于ListView 用于显示多个View集合. 支持页面左右滑动. 如何使用view ...

  7. 【C】——itoa 函数的实现

    itoa函数的实现,函数实现功能:输入一个 int 型的数据然后修改成 十六进制的字符串. 例如:  输入 100  输出 0x64 主函数: int main(void){ ]; my_atoi(v ...

  8. PCL超体聚类

    超体聚类是一种图像的分割方法. 超体(supervoxel)是一种集合,集合的元素是“体”.与体素滤波器中的体类似,其本质是一个个的小方块.与大部分的分割手段不同,超体聚 类的目的并不是分割出某种特定 ...

  9. Sword pcre库使用

    #include <stdlib.h> #include <string.h> #include "regularhelper.h" #include &q ...

  10. ConsoleHelper 类

    //Writes colored text to the console and allows to clear previously written lines //as long a not li ...