java教程

nginx+tomcat+https配置例子 做了一些性能优化

位置:首页 > java教程 > 安装配置,2018-09-15 14:24
这是nginx+tomcat+https配置例子 做了一些性能优化,http跳转到https
server {
listen 80;
server_name  www.ablanxue.com ablanxue.com;
rewrite ^(.*) https://$server_name$1 permanent;
}


server{
       listen 443 ssl;
server_name  www.ablanxue.com ablanxue.com;
if ($http_host !~ '^www\.ablanxue\.com$') {
rewrite ^(.*) http://www.ablanxue.com$1 redirect;
}
    ssl on;	
    ssl_certificate   xxxx.pem;
    ssl_certificate_key  xxxx.key;
    ssl_session_timeout 5m;
    ssl_ciphers ALL:!kEDH!ADH:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP;
    ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers on;


        index index.jsp index.html index.htm;
	    root F:/www.ablanxue.com/webapps/ROOT/;
        #动态页面交给http://127.0.0.1:8080,也即我们之前在nginx.conf定义的upstream aTestServer 均衡
        location ~ .*\.(jsp|action|html)?$ {

client_max_body_size    16m;
 client_body_buffer_size 128k;
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 https;
              proxy_next_upstream   off;
              proxy_connect_timeout   30;
              proxy_read_timeout      300;
              proxy_send_timeout      300;
proxy_pass http://ablanxue;

        }
        #配置Nginx动静分离,定义的静态页面直接从项目指定目录读取。
        location ~ .*\.(shtml|gif|jpg|jpeg|bmp|png|ico|txt|js|css|zip|rar)$ {
        access_log off;
        expires 30d;
        }
		location ~ /WEB-INF/{
    return 404;
}

    }

TAGS:nginx+tomcat+https

猜你喜欢

NewHot