Nginx+tomcat+ssl免费证书配置
0.说明
本文说描写叙述的方式是用nginx的443重定向到tomcat的8443,nginx的80port重定到tomcat的8080;
乱入:个人标记:caicongyang
1.nginx安装
能够參考我前面的文章:Linux tar包安装Nginx ;http://blog.csdn.net/caicongyang/article/details/46388845
只是这篇文章中。我们编译的时候没有带ssl模块。因此须要又一次编译安装
须要在安装时带上ssl模块的选项
完毕命令例如以下:
#./configure --with-http_ssl_module
当然你能够用下面命令查看全部的编译选项
#./configure --help
2.nginx生成免费证书
# cd /opt/nginx/sslkey/
# 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
3.tomcat配置
<Connector port="8443" protocol="org.apache.coyote.http11.Http11Protocol"
maxThreads="150" SSLEnabled="true" scheme="https" secure="true"
clientAuth="false" sslProtocol="TLS" keystoreFile="${user.home}/.
keystore" keystorePass="123456"/>
我的tomcat证书是又一次在生成的:(当前用户路径下)
#keytool -v -genkey -alias tomcat -keyalg RSA -keystore .keystore -validity 36500
当然你也能够指定文件夹
#keytool -v -genkey -alias tomcat -keyalg RSA -keystore /opt/tomcat/sslkey/server.keystore -validity 36500
当然你也能够在项目的web.xml中配置某个重要模块强制使用https,其它的模块正常走http
web.xml
<security-constraint>
<web-resource-collection>
<web-resource-name>services</web-resource-name>
<url-pattern>/login/*</url-pattern>
</web-resource-collection>
<user-data-constraint>
<transport-guarantee>CONFIDENTIAL</transport-guarantee>
</user-data-constraint>
</security-constraint>
以上配置规定路径带login的所有走https
4.nginx配置
#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 {
server localhost:8080 weight=10;
} upstream tomcat8443 {
server localhost:8443 weight=10;
} server {
listen 80;
server_name localhost; #charset koi8-r; #access_log logs/host.access.log main; location / {
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_pass http://tomcat8080;
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} # another virtual host using mix of IP-, name-, and port-based configuration
#
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias; # location / {
# root html;
# index index.html index.htm;
# }
#} # HTTPS server server {
listen 443;
server_name localhost; ssl on;
ssl_certificate /opt/nginx/sslkey/server.crt;
ssl_certificate_key /opt/nginx/sslkey/server.key; ssl_session_timeout 5m; ssl_protocols SSLv2 SSLv3 TLSv1;
ssl_ciphers HIGH:!aNULL:!MD5;
ssl_prefer_server_ciphers on; location / {
proxy_pass https://tomcat8443;
proxy_set_header Host $host:443;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
}
不懂运维的程序猿,不是好的project师!
我的个人站点:http://www.caicongyang.com
我的CSDN博客地址: http://blog.csdn.net/caicongyang
Nginx+tomcat+ssl免费证书配置的更多相关文章
- Nginx+Tomcat的服务器端环境配置详解
这篇文章主要介绍了Nginx+Tomcat的服务器端环境配置详解,包括Nginx与Tomcat的监控开启方法,需要的朋友可以参考下 Nginx+tomcat是目前主流的Javaweb架构,如何让ngi ...
- Nginx+Tomcat+MemCached 集群配置手册
系统实施文档 Nginx+Tomcat+MemCached 集群配置手册 目 录 第1章 概述 1.1 目标 互联网的快速发展带来了互联网系统的高负载和高可用性, 这要求我们在设计系统架 ...
- nginx支持ssl双向认证配置
nginx支持ssl双向认证配置 listen 443; server_name test.com; ssl on; ssl_certificate server.crt; //server端公钥 s ...
- 阿里云https免费证书配置-包教会
阿里云https免费证书配置-包教会-有需要请联系小编! 小编个人站点:https://www.itdog.site/ 小编微信号:wvqusrtg
- CentOS 6.5 nginx+tomcat+ssl配置
本文档用于指导在CentOS 6.5下使用nginx反向代理tomcat,并在nginx端支持ssl. 安装nginx.参见CentOS 6 nginx安装. SSL证书申请.参见腾讯SSL证书申请和 ...
- HappyAA服务器部署笔记1(nginx+tomcat的安装与配置)
这是本人的服务器部署笔记.文章名称叫"部署笔记1"的原因是之后我对这个进行了改进之后,会有"部署笔记2","部署笔记3"...循序渐进,估计 ...
- centos安装配置nginx,ssl生产和配置教程
[一]nginx安装nginx安装带ssl扩展: cd /usr/local/src #进入用户目录wget http://nginx.org/download/nginx-1.15.0.tar.gz ...
- 阿里云使用ssl免费证书
购买免费证书 购买之后 申请证书 该域名必须添加一条TXT记录 根据提示添加记录 下载证书 我用的nginx做的映射,所以下载nginx nginx安装自行百度 将下载的文件解压到nginx目录下(创 ...
- nginx 安装SSL安全证书
安装证书 文件说明: 1. 证书文件214051493730988.pem,包含两段内容,请不要删除任何一段内容. 2. 如果是证书系统创建的CSR,还包含:证书私钥文件214051493730988 ...
随机推荐
- Android学习路线(十二)Activity生命周期——启动一个Activity
DEMO下载地址:http://download.csdn.net/detail/sweetvvck/7728735 不像其他的编程模式那样应用是通过main()函数启动的.Android系统通过调用 ...
- 【LeetCode-面试算法经典-Java实现】【064-Minimum Path Sum(最小路径和)】
[064-Minimum Path Sum(最小路径和)] [LeetCode-面试算法经典-Java实现][全部题目文件夹索引] 原题 Given a m x n grid filled with ...
- less14 颜色函数2
less div{ // hue()色相值 z-index: hue(hsl(90,100%,50%)); //90 ////saturation()饱和度 z-index: saturation(h ...
- thinkphp5项目--个人博客(六)
thinkphp5项目--个人博客(六) 项目地址 fry404006308/personalBlog: personalBloghttps://github.com/fry404006308/per ...
- 解决Linux下yum安装无法解析URL的问题
问题: [root@yaya ~]# yum -y install gcc-* Loaded plugins: fastestmirror, presto Could not retrieve mir ...
- POJ 3013 Dijkstra
从1节点最短路,,然后再乘一下权值就OK了 //By SiriusRen #include <queue> #include <cstdio> #include <cst ...
- 集合HashSet的使用
集合中的HashSet底层是通过Hash表实现,HashSet的特点是元素唯一,但用到Hash表就跟hashCode()有了密不可分的联系,所以HashSet的唯一性是通过hashCode()方法来保 ...
- PostgreSQL 批量生成数据
create table user_info(userid int,name text,birthday date,crt_time timestamp without time zone,); in ...
- 洛谷 P2542 [AHOI2005]航线规划 树链剖分_线段树_时光倒流_离线
Code: #include <map> #include <cstdio> #include <algorithm> #include <cstring&g ...
- 洛谷3964 [TJOI2013]松鼠聚会
题目描述 草原上住着一群小松鼠,每个小松鼠都有一个家.时间长了,大家觉得应该聚一聚.但是草原非常大,松鼠们都很头疼应该在谁家聚会才最合理. 每个小松鼠的家可以用一个点x,y表示,两个点的距离定义为点( ...