<VirtualHost *:9876>
#ServerName 127.0.0.1:9876
ServerAlias
ProxyRequests Off
DocumentRoot "/home/idms/dist"
<Directory "/home/idms/dist">
Options -Indexes
AllowOverride All
Require all granted
</Directory>
# 反代设置
<Proxy balancer://mycluster/>
BalancerMember http://127.0.0.1:8765/api route=assets1 loadfactor=5 connectiontimeout=5 timeout=5
</Proxy>
ProxyPass /api/ balancer://mycluster/
ProxyPassReverse /api/ balancer://mycluster/
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
# 警告:以下这段配置仅用于调试,绝不要添加到生产环境中!!!
CustomLog "logs/apache2.log" combined
ErrorLog "logs/apache2.error.log"
</VirtualHost>
<VirtualHost *:19876>
#ServerName 127.0.0.1:19876
ServerAlias
ProxyRequests Off
DocumentRoot "/home/rms/dist"
<Directory "/home/rms/dist">
Options -Indexes
AllowOverride All
Require all granted
</Directory>
# 反代设置
<Proxy balancer://mycluster/>
BalancerMember http://127.0.0.1:28008/rms route=assets1 loadfactor=5 connectiontimeout=5 timeout=5
</Proxy>
ProxyPass /rms/ balancer://mycluster/
ProxyPassReverse /rms/ balancer://mycluster/
SetEnv force-proxy-request-1.0 1
SetEnv proxy-nokeepalive 1
# 警告:以下这段配置仅用于调试,绝不要添加到生产环境中!!!
CustomLog "logs/apache2.log" combined
ErrorLog "logs/apache2.error.log"
</VirtualHost>
/api只是地址的标识,例如本来后缀是/mgr,经过gateway设置后变为/api/mgr,那这样也是可以的
virtualhost只是apache要展示的前端资源,后面访问资源会暴露真实的端口和地址,所以需要反向代理,负载均衡是为了缓解服务器压力。