nginx1.6.2+tomcat8.0.36 配置https
2016-06-21 23:40
393 查看
https秘钥相关
keytool -genkey -alias joinku -keyalg RSA -keypass {密码} -storepass {密码} -keystore server.keystore -validity 3600
所有信息都是填写:joinku ,生成文件 server.keystore 。
存放目录在$CATALINA_HOME/conf下的server.keystore
修改 tomcat下的server.xml
SSL配置
<Connector port="18443"
protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="/usr/local/tomcat/conf/server.keystore" keystorePass="{密码}"
clientAuth="false" sslProtocol="TLS" />
server.keystore
Nginx https 配置
生成证书
$ cd /usr/local/nginx/conf
$ openssl genrsa -des3 -out server.key 1024
$ openssl req -new -key server.key -out server.csr
$ cp server.key server.key.org
$ openssl rsa -in server.key.org -out server.key
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
nginx 需要支持https ,如果需要源码编译,则需要打开 ssl 模块,否则会报告 配置文件中 的 ssl on; 非法的错误
./configure --with-http_ssl_module --prefix=/usr/local/nginx
配置nginx ,不改变原来的server配置部分,新建一个server ,专门监听443端口
server {
listen 443 ;
server_name localhost;
charset utf-8;
# https 配置
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
location ~* \.(htm)$ {
root html;
index index.html index.htm;
proxy_pass http://web_boss;
proxy_set_header Host $http_host;
proxy_set_header Cookie $http_cookie;
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;
client_max_body_size 100m;
}
}
keytool -genkey -alias joinku -keyalg RSA -keypass {密码} -storepass {密码} -keystore server.keystore -validity 3600
所有信息都是填写:joinku ,生成文件 server.keystore 。
存放目录在$CATALINA_HOME/conf下的server.keystore
修改 tomcat下的server.xml
SSL配置
<Connector port="18443"
protocol="org.apache.coyote.http11.Http11NioProtocol" SSLEnabled="true"
maxThreads="150" scheme="https" secure="true"
keystoreFile="/usr/local/tomcat/conf/server.keystore" keystorePass="{密码}"
clientAuth="false" sslProtocol="TLS" />
server.keystore
Nginx https 配置
生成证书
$ cd /usr/local/nginx/conf
$ openssl genrsa -des3 -out server.key 1024
$ openssl req -new -key server.key -out server.csr
$ cp server.key server.key.org
$ openssl rsa -in server.key.org -out server.key
$ openssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt
nginx 需要支持https ,如果需要源码编译,则需要打开 ssl 模块,否则会报告 配置文件中 的 ssl on; 非法的错误
./configure --with-http_ssl_module --prefix=/usr/local/nginx
配置nginx ,不改变原来的server配置部分,新建一个server ,专门监听443端口
server {
listen 443 ;
server_name localhost;
charset utf-8;
# https 配置
ssl on;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
location ~* \.(htm)$ {
root html;
index index.html index.htm;
proxy_pass http://web_boss;
proxy_set_header Host $http_host;
proxy_set_header Cookie $http_cookie;
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;
client_max_body_size 100m;
}
}
相关文章推荐
- 12-227 网络客户端开发(TCP)
- scapyd scrapyd-client scrapy使用http调度spider.md
- AngularJs练习Demo9 Http
- 利用FastJson来解析网络数据
- HTTP协议/RTSP协议/RTMP协议的区别
- HTTP与HTTPS的区别
- tcp总结
- linux网络编程-----实现并发访问网站------
- 使用HOG特征+BP神经网络进行车标识别
- 网络编程常见类型定义
- TCP/IP协议
- 【网络编程5】Java与Python套接字Socket通信的例子
- C#检测本地网络状态
- 详解https是如何确保安全的?
- 使用Http-only Cookie来防止XSS攻击
- HTTP学习笔记——报文格式
- TCP三次握手(建立连接)/四次挥手(关闭连接)
- 深入理解nginx chap3 开发一个简单的HTTP模块
- OkHttp使用(二)加载图片及下载文件
- OkHttp使用(一)基本使用