PHP 反向代理
基于 https://github.com/jshensh/php-curl-class 的一个应用
需要修改的配置文件
nginx.conf
请替换 Line 5 的域名以及 Line 7 的实际路径
index.php
请替换 Line 6 的源站访问协议、Line 7 的源站域名以及 Line 8 的当前站点域名,Line 154 起的输出内容替换数组视情况修改
功能
转发用户的 GET 请求 转发用户的 POST 请求 转发用户的 PUT 请求 转发用户的 DELETE 请求 转发用户发送的所有 Header(除 Accept-Encoding 和 Host) 转发服务器返回的所有 Header(除 Content-Length 和 Content-Encoding) 替换服务器返回的内容搭建反代(基于 lnmp)
#!/bin/sh originProtocol="http" originSite="baidu.com" thisSite="example.com" # 以上三行需要修改 cd /home/wwwroot git clone https://github.com/jshensh/phpReverseProxy ${thisSite} rm -rf ${thisSite}/.git/ cd ${thisSite} sed -i "s/example.com/${thisSite}/g" ./nginx.conf mv ./nginx.conf /usr/local/nginx/conf/vhost/${thisSite}.conf sed -i "s/http/${originProtocol}/g" ./index.php sed -i "s/example.com/${thisSite}/g" ./index.php sed -i "s/baidu.com/${originSite}/g" ./index.php composer install chown -R www:www ./* lnmp nginx reload
版权声明:
1、该文章(资料)来源于互联网公开信息,我方只是对该内容做点评,所分享的下载地址为原作者公开地址。2、网站不提供资料下载,如需下载请到原作者页面进行下载。
3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考学习用!
4、如文档内容存在违规,或者侵犯商业秘密、侵犯著作权等,请点击“违规举报”。