---
title: "nginx启用https 443"
author: "jdkleo"
date: "2015-09-12T11:19:12Z"
tags: []
categories: ["开源软件"]
slug: "nginx-https-443"
draft: false
lastmod: "2015-10-08T13:49:53Z"
id: 2242870
url: "https://jdkleo.iteye.com/blog/2242870"
---

**一、安装nginx并启用ssl模块**

   **before**

```
svn checkout http://nginx-upstream-jvm-route.googlecode.com/svn/trunk/ /root/dev/nginx-upstream-jvm-route-read-only
```

 

```
patch -p0 < /root/dev/nginx-upstream-jvm-route-read-only/jvm_route.patch
./configure --prefix=/usr/local/nginx --with-http_ssl_module --with-http_stub_status_module --add-module=/root/dev/nginx-upstream-jvm-route-read-only/
make && make install
```

 **二、生成SSL证书**

```
#cd /usr/local/nginx/conf
#openssl genrsa -des3 -out server.key 1024
#openssl req -new -key server.key -out server.csr
#openssl rsa -in server.key -out server_nopwd.key
#openssl x509 -req -days 3650 -in server.csr -signkey server_nopwd.key -out server.crt
```

 **三、配置HTTPS**

```
server {
    listen 443;
    ssl on;
    ssl_certificate  /usr/local/nginx/conf/server.crt;
    ssl_certificate_key  /usr/local/nginx/conf/server_nopwd.key;
}
```

 **四、启动NGINX**

```
/usr/local/nginx/sbin/nginx -s reload（重启，首次启动不用加任何参数）
```

 **五、访问**

```
https://xxx.xxx.xxx.xxx
```

 **六、参考**

http://www.cnblogs.com/tintin1926/archive/2012/07/12/2587311.html

http://www.cnblogs.com/zhuhongbao/archive/2013/06/04/3118061.html

 

注意proxy\_pass的地址和upstream保持一致的名称