apache 实现反向代理的两种方法 作者:七棵菜 日期:2022-11-30 栏目:计算机分类:1 人气:446 apache实现反向代理有两种方法,在使用之前需要放开**反向代理**模块 ``` LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_http_module modules/mod_proxy_http.so ``` - 使用`RewriteRule` 如下为`apache`2.4版本`.htaccess`的配置 ``` <IfModule mod_rewrite.c> Options +FollowSymlinks -Multiviews RewriteEngine On # 重写规则的参数 # P,使用反向代理,如果忽略则表示重定向 # L,终止下面的规则 # `/Art`目录跳转到`http://localhost:8081/Art` RewriteCond %{REQUEST_URI} ^/Art RewriteRule (.*) http://localhost:8081/$1 [P,L,E=PATH_INFO:$1] # `uploads`目录跳转到`http://localhost:8081/Art/uploads` RewriteCond %{REQUEST_URI} ^/.*/uploads RewriteRule .*/uploads/(.*) http://localhost:8081/Art/uploads/$1 [P,L,E=PATH_INFO:$1] </IfModule> ``` - 使用`ProxyPass` ``` ProxyPass /Art http://localhost:8081/Art ProxyPassReverse /Art http://localhost:8081/Art ProxyPassMatch ^(.*)/uploads http://localhost:8081/Art/uploads ``` 标签: ProxyPass apache 反向代理 RewriteRule ProxyPassReverse ProxyPassMatch 上一篇:如何使用mvn命令导入依赖 下一篇:javascript 不同时区时间对比引起的问题 随便看看 2024-02-19 PHP7 运算符“??” 和“?:”的区别 2022-11-30 Linux 后台运行命令 2022-11-25 关于我们 2022-11-30 centos一键系统安装lnmp集成环境 2022-11-30 linux 生成 ssh 公钥 留言