Nginx动态文件与静态文件分离的方法
时间:2014-08-14 11:34 来源:linux.it.net.cn 作者:it
nginx中配置动静分离
首先,安装nginx:
复制代码代码示例:
[root@jbxue.com /]# rpm -ivh /nginx-0.6.36-1.el5.i386.rpm
主配置文件nginx.conf
复制代码代码示例:
[root@jbxue.com /]# cd /etc/nginx/
[root@jbxue.com nginx]# ls nginx.conf
nginx.conf
[root@jbxue.com nginx]# vim /etc/nginx/nginx.conf
location / {
81 root /usr/share/nginx/html;
82 index index.html index.htm;
83 }
nginx的主目录/usr/share/nginx/html
默认主页index.html index.htm;
在logformat下面添加:
复制代码代码示例:
upstream nginx{
server 192.168.1.27:80;
}
upstream tomcat{
server 192.168.1.25:8080;
}
location / {
if( $request_uri ~* ".*\.html$"){
proxy_pass http://nginx;
}
proxy_pass http://tomcat;
}
注意:
与ldirector整合时,验证的网页也要写一个。
(责任编辑:IT)
nginx中配置动静分离
首先,安装nginx:
复制代码代码示例:
[root@jbxue.com /]# rpm -ivh /nginx-0.6.36-1.el5.i386.rpm
主配置文件nginx.conf
复制代码代码示例:
[root@jbxue.com /]# cd /etc/nginx/
[root@jbxue.com nginx]# ls nginx.conf nginx.conf [root@jbxue.com nginx]# vim /etc/nginx/nginx.conf location / { 81 root /usr/share/nginx/html; 82 index index.html index.htm; 83 }
nginx的主目录/usr/share/nginx/html
在logformat下面添加:
复制代码代码示例:
upstream nginx{
}
注意: |