nginx开启gzip压缩,再将动态api数据请求通过nginx反向代理转发到tomcat.
配置示例:
#user nobody;worker_processes 4;error_log logs/error.log;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;tcp_nodelay on;keepalive_timeout 65;types_hash_max_size 2048;gzip on;gzip_http_version 1.0;gzip_min_length 1024;gzip_buffers 4 16k;gzip_comp_level 3;gzip_proxied any;gzip_disable "MSIE [1-6].";gzip_types text/plain application/json application/x-javascript text/css text/javascript application/octet-stream application/javascript application/xml application/x-httpd-php image/jpeg image/gif image/png;server {listen 9090;server_name 10.47.58.89:9090;root /data/apps/tomcat/webapps/ROOT/WEB-INF/classes/static/;location = / {expires -1;rewrite / /index.html break;}location ~ ^/(lib)/ {expires 30d;}location = /page/index.html {expires -1;}location = /page/blog.html {expires -1;}location = /page/gantt/index.html {expires -1;}location ~ ^/(admin/(js|css|img|md)|img|landing|page|scripts|themes|swipebox)/ {expires 12h;}location / {proxy_set_header Upgrade $http_upgrade;proxy_set_header Connection "upgrade";proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;proxy_set_header Host $host;proxy_http_version 1.1;proxy_headers_hash_max_size 51200;proxy_headers_hash_bucket_size 6400;#proxy_redirect off;proxy_set_header Host $host:$server_port;proxy_set_header X-Real-IP $remote_addr;proxy_set_header REMOTE-HOST $remote_addr;proxy_set_header X-Forwarded-Host $host;proxy_set_header X-Forwarded-Server $host;proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;client_max_body_size 50m;proxy_pass http://localhost:8080/;}}}
