name: apache 部署

sort: 4

Apache 配置

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

  1. NameVirtualHost *:80
  2. <VirtualHost *:80>
  3. ServerAdmin webmaster@dummy-host.example.com
  4. ServerName www.a.com
  5. ProxyRequests Off
  6. <Proxy *>
  7. Order deny,allow
  8. Allow from 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. ProxyRequests Off
  17. <Proxy *>
  18. Order deny,allow
  19. Allow from all
  20. </Proxy>
  21. ProxyPass / http://127.0.0.1:8081/
  22. ProxyPassReverse / http://127.0.0.1:8081/
  23. </VirtualHost>