Apache 配置

apache 和 nginx 的实现原理一样,都是做一个反向代理,把请求向后端传递,配置如下所示:

  1. NameVirtualHost*:80
  2. <VirtualHost*:80>
  3. ServerAdmin webmaster@dummy-host.example.com
  4. ServerName www.a.com
  5. ProxyRequestsOff
  6. <Proxy*>
  7. Order deny,allow
  8. Allowfrom all
  9. </Proxy>
  10. ProxyPass/ http://127.0.0.1:8080/
  11. ProxyPassReverse/ http://127.0.0.1:8080/
  12. </VirtualHost>
  13. <VirtualHost*:80>
  14. ServerAdmin webmaster@dummy-host.example.com
  15. ServerName www.b.com
  16. ProxyRequestsOff
  17. <Proxy*>
  18. Order deny,allow
  19. Allowfrom all
  20. </Proxy>
  21. ProxyPass/ http://127.0.0.1:8081/
  22. ProxyPassReverse/ http://127.0.0.1:8081/
  23. </VirtualHost>