650) this.width=650; "src=" http://s3.51cto.com/wyfs02/M00/72/90/wKiom1XmnUuja0nMAACNkbOZ8S8165.jpg "title=" 11.png "alt=" Wkiom1xmnuuja0nmaacnkboz8s8165.jpg "/>
1. Experimental environment:
Machine
10.0.10.8 Nginx Proxy
10.0.10.12 Nginx Static
10.0.10.10 ngins Dynamic, LNMP platform, with a tomcat service
System version and Kernel
# Cat/etc/redhat-release
CentOS Release 6.6 (Final)
# Uname-r
2.6.32-504.3.3.el6.x86_64
2, Nginx static server configuration file
# cat/application/nginx/conf/nginx.conf
Worker_processes 1;
Events {
Worker_connections 1024;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Sendfile on;
Keepalive_timeout 65;
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;
server {
Listen 80;
server_name www.cui.com;
Location/{
root/data/www;
Index index.html index.htm;
}
}
}
simple Web content and images
# cat/data/www/index.html
<body>
This is static site!!
</body>
# ls/data/www/
1.png Images index.html Tomcat.png
3. nginx Dynamic Server configuration file
# cat/application/nginx/conf/nginx.conf
Worker_processes 1;
Events {
Worker_connections 1024;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Sendfile on;
Keepalive_timeout 65;
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;
server {
Listen 80;
server_name www.cui.com;
root/data/www;
Location/{
root/data/www;
Index index.php index.html index.htm;
}
Location ~. *\. (PHP|PHP5)? $ {
Fastcgi_pass 127.0.0.1:9000;
Fastcgi_index index.php;
Include fastcgi.conf;
}
}
}
Simple Web content
# cat/data/www/index.php
<?php
echo "This is PHP dynamic site!! \ n ";
?>
4. Nginx Proxy Server configuration file
# cat/application/nginx/conf/nginx.conf
Worker_processes 1;
Events {
Worker_connections 1024;
}
HTTP {
Include Mime.types;
Default_type Application/octet-stream;
Sendfile on;
Keepalive_timeout 65;
Server_tokens off;
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;
Include proxy.conf;#proxy一些优化
Upstream Static_pools {
Server 10.0.10.12:80 weight=1 max_fails=10 fail_timeout=10s;
}
Upstream Nginx_pools {
Server 10.0.10.10:80 weight=1 max_fails=10 fail_timeout=10s;
}
Upstream Tomcat_pools {
Server 10.0.10.10:8080 weight=1 max_fails=10 fail_timeout=10s;
}
server {
Listen 80;
server_name www.cui.com;
#location/{
# index index.html index.htm;
# Proxy_pass Http://static_pools;#这里可以设置, can also not set, set to static default to find static, set to dynamic default to find dynamic
#}
Location ~* \. (html|js|css|gif|jpg|jpeg|png|bmp|swf) $ {
Proxy_pass Http://static_pools;
}
Location ^~/images/{
Proxy_pass Http://static_pools;
}
Location ~. *. (php|cgi|jhtml) $ {
Proxy_pass Http://nginx_pools;
}
Location ~. *. (JSP) $ {
Proxy_pass Http://tomcat_pools;
}
}
}
Proyx optimized configuration files
# cat/application/nginx/conf/proxy.conf
Proxy_redirect off;
Proxy_set_header Host $host;
Proxy_set_header x-forwarded-for $remote _addr;
Proxy_connect_timeout 90;
Proxy_send_timeout 90;
Proxy_read_timeout 90;
Proxy_buffer_size 4k;
Proxy_buffers 4 32k;
Proxy_busy_buffers_size 64k;
Proxy_temp_file_write_size 64k;
5. Verification Effect
1. The following is the default access to the static Web page
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/8C/wKioL1XmoAaSXiwPAAB5bv7M5jg289.jpg "title=" Jintai.png "alt=" Wkiol1xmoaasxiwpaab5bv7m5jg289.jpg "/>
2. The following is a static picture of the access to the end of PNG
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/8D/wKioL1XmoPjRb-bBAALKtRUXfVI350.jpg "title=" Jingtai01.png "alt=" wkiol1xmopjrb-bbaalktruxfvi350.jpg "width=" 650 "/>
3. The following is a static picture of the images directory accessed
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/90/wKiom1Xmn1nRSJu6AAU8_ATDZBg052.jpg "title=" Jingtai02.png "alt=" wkiom1xmn1nrsju6aau8_atdzbg052.jpg "width=" 650 "/>
4. The following is a visit to a dynamic Web page ending in PHP
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M02/72/8D/wKioL1Xmoa2AhP-6AACa8OHkN-U987.jpg "title=" Dynamic01.png "alt=" Wkiol1xmoa2ahp-6aaca8ohkn-u987.jpg "/>
5. The following is a visit to the Tomcat Server JSP Web page
650) this.width=650; "src=" Http://s3.51cto.com/wyfs02/M00/72/8D/wKioL1XmoeWhV5p1AAGk02R6F6I787.jpg "title=" Dynamic02.png "alt=" wkiol1xmoewhv5p1aagk02r6f6i787.jpg "width=" 650 "/>
This article is from the It Dick thread blog, so be sure to keep this source http://68686789.blog.51cto.com/10438688/1692577
Static and dynamic separation of Nginx reverse proxy