Nginx做前端处理静态页,apache+php处理动态页
2014-09-26 16:56
423 查看
Nginx配置
在nginx的conf中创建proxy_apache.conf
内容如下
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_connect_timeout 30;
proxy_read_timeout 60;
proxy_send_timeout 30;
proxy_buffer_size 4k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 128k;
client_max_body_size 10m;
client_body_buffer_size 128k;
虚拟主机配置
server
{
listen 80;
server_name www.http.com;
index index.html index.htm index.php default.html default.htm default.php;
root /data/htdocs/http;
access_log /usr/local/nginx/logs/http_access.log www;
error_log /usr/local/nginx/logs/http_error.log;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ \.php$ {
proxy_pass http://127.0.0.1:8080;
include proxy_apache.conf;
proxy_redirect http://127.0.0.1:8080/ http://www.http.com/;
}
location / {
try_files $uri $uri/ @apache;
}
location @apache {
proxy_pass http://127.0.0.1:8080;
include proxy_apache.conf;
proxy_redirect http://127.0.0.1:8080/ http://www.http.com/;
}
}
httpd配置
<VirtualHost *:8080>
ServerName www.http.com
DocumentRoot "/data/htdocs/http"
</VirtualHost>
在nginx的conf中创建proxy_apache.conf
内容如下
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_connect_timeout 30;
proxy_read_timeout 60;
proxy_send_timeout 30;
proxy_buffer_size 4k;
proxy_buffers 16 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 128k;
client_max_body_size 10m;
client_body_buffer_size 128k;
虚拟主机配置
server
{
listen 80;
server_name www.http.com;
index index.html index.htm index.php default.html default.htm default.php;
root /data/htdocs/http;
access_log /usr/local/nginx/logs/http_access.log www;
error_log /usr/local/nginx/logs/http_error.log;
location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 30d;
}
location ~ .*\.(js|css)?$
{
expires 12h;
}
location ~ \.php$ {
proxy_pass http://127.0.0.1:8080;
include proxy_apache.conf;
proxy_redirect http://127.0.0.1:8080/ http://www.http.com/;
}
location / {
try_files $uri $uri/ @apache;
}
location @apache {
proxy_pass http://127.0.0.1:8080;
include proxy_apache.conf;
proxy_redirect http://127.0.0.1:8080/ http://www.http.com/;
}
}
httpd配置
<VirtualHost *:8080>
ServerName www.http.com
DocumentRoot "/data/htdocs/http"
</VirtualHost>
相关文章推荐
- Ubuntu下Nginx做前端代理Apache端口做处理PHP动态请求
- Ubuntu下Nginx做前端调用Apache做PHP动态请求处理
- Nginx使用Apache的php处理后台
- Nginx前端设置反向代理,后端Apache如何获取访客的真实IP,结合PHP
- nginx做前端转发,将php交给php-fpm处理(nginx+php-fpm)
- nginx+apache+mysql+php+memcached+squid搭建门户网站
- [转]Nginx 0.5.33 + PHP 5.2.5(FastCGI)搭建胜过Apache 10倍的Web服务器(第2版)
- Nginx 0.7.x + PHP 5.2.9(FastCGI)搭建胜过Apache十倍的Web服务器(第5版)
- Nginx 0.7.x + PHP 5.2.10(FastCGI)搭建胜过Apache十倍的Web服务器 安装与配置(3)
- linux下查看nginx,apache,mysql,php的编译参数
- 搭建高性能Web服务器Nginx,10倍于Apache---Nginx+Php(FastCgi模式)
- 搭建高性能Web服务器Nginx,10倍于Apache---Nginx+Php(FastCgi模式)
- 利用nginx+apache+mysql+php+memcached+squid搭建门户
- 给apache2.2加上mod_encoding模块後 php5.2.0 处理url出现bug
- nginx+apache+mysql+php+memcached+squid搭建门户网站
- 《APMServ 5.2.6》:一键快速搭建Apache+PHP+MySQL+Nginx+Memcached+ASP平台的绿色软件[原创]
- PHP中静态页处理动态内容的思路
- Nginx 0.7.x + PHP 5.2.6(FastCGI)搭建胜过Apache十倍的Web服务器
- Nginx 0.5.33 + PHP 5.2.5(FastCGI)搭建胜过Apache 10倍的Web服务器(第2版)[原创]
- Nginx 0.7.x + PHP 5.2.9(FastCGI)搭建胜过Apache十倍的Web服务器