博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
linux下 nginx 转发内容至 本地 apache
阅读量:4614 次
发布时间:2019-06-09

本文共 1772 字,大约阅读时间需要 5 分钟。

流量从本地80端口的nginx进来之后在转发给本地apache的88端口,在什么环境下会用到这种配置还有待观察,这里先做个记录

先配置 nginx 的配置文件 xxx.conf  如图

server {        listen       80;        server_name xxxx.com www.xxx.com;        root /www/xxx;        index  index.html index.php index.htm;        error_page  400 /errpage/400.html;        error_page  403 /errpage/403.html;        error_page  404 /errpage/404.html;        location ~ \.php$ {                proxy_pass http://127.0.0.1:88;                include naproxy.conf;        }        location / {                try_files $uri @apache;        }        location @apache {                 proxy_pass http://127.0.0.1:88;                 include naproxy.conf;        }}

接下来在配置 apache 

DocumentRoot /www/xxxxServerName xxxx.comServerAlias www.xxxx.comErrorDocument 400 /errpage/400.htmlErrorDocument 403 /errpage/403.htmlErrorDocument 404 /errpage/404.htmlphp_admin_value open_basedir /www/xxxx:/tmp
DeflateCompressionLevel 7AddOutputFilterByType DEFLATE text/html text/plain text/xml application/x-httpd-phpAddOutputFilter DEFLATE css js html htm gif jpg png bmp php
Options FollowSymLinks AllowOverride All Order allow,deny Allow from all

再分别重启 apache 和 nginx  即可

下图是naproxy.conf的配置图

proxy_connect_timeout 30s;proxy_send_timeout   90;proxy_read_timeout   90;proxy_buffer_size    32k;proxy_buffers     4 32k;proxy_busy_buffers_size 64k;proxy_redirect     off;proxy_hide_header  Vary;proxy_set_header   Accept-Encoding '';proxy_set_header   Host   $host;proxy_set_header   Referer $http_referer;proxy_set_header   Cookie $http_cookie;proxy_set_header   X-Real-IP  $remote_addr;proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;

  

如果服务器配置较低则不推荐这么做

 

转载于:https://www.cnblogs.com/zyjfire/p/10136777.html

你可能感兴趣的文章
file_get_contents()获取https出现这个错误Unable to find the wrapper “https” – did
查看>>
linux vi编辑器
查看>>
js树形结构-----(BST)二叉树增删查
查看>>
contract
查看>>
FJUT ACM 1899 Largest Rectangle in a Histogram
查看>>
如何删除xcode项目中不再使用的图片资源
查看>>
编写用例文档
查看>>
解决WPF两个图片控件显示相同图片因线程占用,其中一个显示不全的问题
查看>>
寻觅Azure上的Athena和BigQuery (二):神奇的PolyBase
查看>>
编程题练习
查看>>
mac os安装vim74
查看>>
Linux内存管理原理
查看>>
Java 8 Lambda 表达式
查看>>
BZOJ-3289 Mato的文件管理
查看>>
自旋锁和互斥锁的区别
查看>>
react混合开发APP,资源分享
查看>>
入门篇
查看>>
【洛谷1829】 [国家集训队] Crash的数字表格(重拾莫比乌斯反演)
查看>>
[转]免费api大全
查看>>
git 认证问题之一的解决 : http ssh 互换
查看>>