与Apache配合使用

  1. LoadModule proxy_module /yourpath/modules/mod_proxy.so
  2. LoadModule proxy_balancer_module /yourpath/modules/mod_proxy_balancer.so
  3. LoadModule lbmethod_byrequests_module /yourpath/modules/mod_lbmethod_byrequests.so
  4. LoadModule proxy_http_module /yourpath/modules/mod_proxy_http.so
  5. LoadModule slotmem_shm_module /yourpath/modules/mod_slotmem_shm.so
  6. LoadModule rewrite_module /yourpath/modules/mod_rewrite.so
  7. LoadModule remoteip_module /yourpath/modules/mod_remoteip.so
  8. LoadModule deflate_module /yourpath/modules/mod_deflate.so
  9. <IfModule deflate_module>
  10. SetOutputFilter DEFLATE
  11. DeflateCompressionLevel 2
  12. AddOutputFilterByType DEFLATE text/html text/plain text/css text/javascript application/json application/javascript application/x-javascript application/xml application/x-httpd-php image/jpeg image/gif image/png font/ttf font/otf image/svg+xml
  13. </IfModule>
  14. <VirtualHost *:80>
  15. # 别忘了绑Host
  16. ServerName www.laravels.com
  17. ServerAdmin hhxsv5@sina.com
  18. DocumentRoot /yourpath/laravel-s-test/public;
  19. DirectoryIndex index.html index.htm
  20. <Directory "/">
  21. AllowOverride None
  22. Require all granted
  23. </Directory>
  24. RemoteIPHeader X-Forwarded-For
  25. ProxyRequests Off
  26. ProxyPreserveHost On
  27. <Proxy balancer://laravels>
  28. BalancerMember http://192.168.1.1:5200 loadfactor=7
  29. #BalancerMember http://192.168.1.2:5200 loadfactor=3
  30. #BalancerMember http://192.168.1.3:5200 loadfactor=1 status=+H
  31. ProxySet lbmethod=byrequests
  32. </Proxy>
  33. #ProxyPass / balancer://laravels/
  34. #ProxyPassReverse / balancer://laravels/
  35. # Apache处理静态资源,LaravelS处理动态资源。
  36. RewriteEngine On
  37. RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-d
  38. RewriteCond %{DOCUMENT_ROOT}%{REQUEST_FILENAME} !-f
  39. RewriteRule ^/(.*)$ balancer://laravels/%{REQUEST_URI} [P,L]
  40. ErrorLog ${APACHE_LOG_DIR}/www.laravels.com.error.log
  41. CustomLog ${APACHE_LOG_DIR}/www.laravels.com.access.log combined
  42. </VirtualHost>