Nginx reverse proxy, dynamic static request separation, and Nginx cache application, and use Ngx_cache_purge to clear the specified URL

Source: Internet
Author: User
Tags dedicated server tomcat server nginx reverse proxy

One, Nginx reverse proxy configuration

#tomcat Java code upstream tomcat_server{server 127.0.0.1:8080;   } erver{listen 80;      server_name www.wolfdream.com;         Location/{proxy_redirect off;         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://tomcat_server; }

It is obvious that the user accesses the www.wolfdream.com (you need to set the local localhost and point www.wolfdream.com to Nginx's IP) ( or write the www.wolfdream.com directly at the IP address where the nginx resides, and transfer the request to a Tomcat server in the background, that is, 127.0.0.1:8080, and send the requested data to the client

two, dynamic static request phase separation

God horse meaning. Pictures, js,html and other static things to access a dedicated server, while the dynamic request to access another server. As simple as this, on the example:

  Java code    server {          listen        192.168.154.128:80;          server_ name  image.wolfdream.com;    index index.html;             #proxy_pass  http://tomcat_server;                       #charset  koi8-r;               #access_log   logs/host.access.log  main;                              location / {               root   html;                #index   index.html index.htm;                 proxy_redirect off;          proxy_set_header Host  $host;         proxy_set_header  X-Real-IP  $remote _addr;         proxy_set_header  x-forwarded-for  $proxy _add_x_forwarded_for;                  }                  Location ~ .*\. (gif|jpg|jpeg|png|bmp|swf) $   {               valid_referers none blocked 192.168.154.128 192.168.154.1;        if  ($invalid _referer)        {           rewrite ^  /403.jpg break;        }                                    if  (!-f  $request _filename)  {                     rewrite ^ /404.jpg last;  <

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.