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; <