Nginx + Tomcat implement reverse proxy and dynamic/static Separation

Source: Internet
Author: User
Tags nginx reverse proxy

1. What is dynamic and static separation?

Static and Dynamic separation processes static pages of user-side requests through nginx (or Apache), while Tomcat (or WebLogic) processes dynamic pages, in this way, different containers are used to process static and dynamic pages. 2. why is it much more efficient to process static pages with dynamic/static separation nginx than tomcat? We only want tomcat to do what we are good at and talk to facts, we use AB to perform stress tests on a static page access.
Www.2cto.com 1) Load Testing for nginx processing static pages after static and dynamic separation: # AB-N 1000-C 200 http: // 10.10.11.91/index.html throughput: 1.2 m
Www.2cto.com 2) without static/dynamic separation, Tomcat directly processes the stress test on the same static page: # AB-N 1000-C 200 http: // 10.10.11.91: 8080/index.html: 0.08m passed the above stress test results. All requests are processed by Tomcat and compared with static and dynamic separation, there is no doubt that static and dynamic separation is the king! 3. Logic Diagram of dynamic/static separation 4. nginxand Tomcat deployment are deployed by installing middleware_install_v.1.0.3.tar.gz with one click. 5. Configure nginx as follows:
Www.2cto.com server {Listen 80; SERVER_NAME www.test.com 10.10.11.91; index index.html index.htm index. jsp index. doroot/usr/local/nginx/html; # handle Static Page location ~ By nginx ~ . * \. (GIF | JPG | JPEG | PNG | BMP | SWF) $ {expires 30d;} location ~ . * \. (JS | CSS )? $ {Expires 1 h;} location ~ (\. JSP) | (\. do) $ {proxy_pass http: // 10.10.11.91: 8080; # Tomcat processes proxy_redirect off through nginx reverse proxy on the JSP and do requests page; proxy_set_header host $ host; proxy_set_header X-real-IP $ remote_addr; proxy_set_header X-forwarded-for $ timeout; limit 10 m; Limit 128 K; proxy_connect_timeout 90; proxy_send_timeout 90; Limit 90; limit 4 K; proxy_buffers 4 32 K; proxy_busy_buffers_size 64 K; proxy_temp_file_write_size 64 K;} 6. verify the effect of dynamic and static separation. I have created index.html and test under the root directory rootof tomcat. JSP, test. do three test files: I have created the test homepage index.html under the nginx root directory/usr/local/nginx/html to directly access Tomcat's static homepage: directly access Tomcat's JSP page: directly access Tomcat's. do page: access via nginx now: nginx homepage:
At www.2cto.com, view the nginx JSP page Processing request: view the nginx processing. Do page request: At this point, nginx and tomcat have implemented reverse proxy Dynamic and Static separation.
 

Nginx + Tomcat implement reverse proxy and dynamic/static Separation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.