22
2025
04
14:38:40

phpReverseProxy PHP 反向代理 基于 https://github.com/jshensh/php-curl-class 的一个应用

https://github.com/jshensh/phpReverseProxy


Repository files navigation

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/shoriginProtocol="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




推荐本站淘宝优惠价购买喜欢的宝贝:

image.png

本文链接:https://zblog.hqyman.cn/post/10688.html 非本站原创文章欢迎转载,原创文章需保留本站地址!

分享到:
打赏





休息一下~~


« 上一篇 下一篇 »

发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

请先 登录 再评论,若不是会员请先 注册

您的IP地址是: