Apache mod_proxy and mongrel_rails cluster: good combination?
I’ve been toying with various combinations to get RoR run smooth on FreeBSD. RoR + Mongrel rails cluster + pound was fine; Apache + fcgid + RoR was fine too. The recent test (Apache 2.2.3 + mod_proxy + mongrel rails cluster + RoR) conducted was not going very well. Random crashes on Apache httpd.
Loading related modules:
LoadModule rewrite_module libexec/apache22/mod_rewrite.so
LoadModule proxy_module libexec/apache22/mod_proxy.so
LoadModule proxy_balancer_module libexec/apache22/mod_proxy_balancer.so
LoadModule proxy_http_module libexec/apache22/mod_proxy_http.so
My apache config for the setup was as follow:
<VirtualHost>
ServerAdmin vista@ms.shit.la
DocumentRoot /home/chflags/www/blog/public
ServerName bsd.b3ta.org
<Directory>
Options Indexes FollowSymLinks ExecCGI
AllowOverride None
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
# Reverse proxy to mongrel_cluster
# Warning : By enabling this, you are turning your apache to be proxy server!
# We are doing reverse proxy here.
ProxyRequests Off
<Proxy balancer://chfl4gs>
BalancerMember http://127.0.0.1:8001
BalancerMember http://127.0.0.1:8002
</Proxy>
RewriteEngine On
# Uncomment for rewrite debugging
#RewriteLog logs/your_app_rewrite_log
#RewriteLogLevel 9
# Check for maintenance file and redirect all requests
# I don't need these!
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteCond %{SCRIPT_FILENAME} !maintenance.html
RewriteRule ^.*$ /system/maintenance.html [L]
# Rewrite index to check for static
RewriteRule ^/$ /index.html [QSA]
# Rewrite to check for Rails cached page
RewriteRule ^([^.]+)$ $1.html [QSA]
# Redirect all non-static requests to cluster
RewriteCond %{DOCUMENT_ROOT}/%{REQUEST_FILENAME} !-f
RewriteRule ^/(.*)$ balancer://chflags%{REQUEST_URI} [P,QSA,L]
# Deflate
AddOutputFilterByType DEFLATE text/html text/plain text/xml
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
# Uncomment for deflate debugging
#DeflateFilterNote Input input_info
#DeflateFilterNote Output output_info
#DeflateFilterNote Ratio ratio_info
#LogFormat ‘”%r” %{output_info}n/%{input_info}n (%{ratio_info}n%%)’ deflate
#CustomLog logs/your_app_deflate_log deflate
ProxyPass / balancer://chfl4gs/
ProxyPassReverse / balancer://chfl4gs/
SSLEngine on
SSLCipherSuite ALL:!ADH:!EXPORT56:RC4+RSA:+HIGH:+MEDIUM:+LOW:+SSLv2:+EXP:+eNULL
SSLCertificateFile /usr/local/etc/apache22/ssl/bsd.b3ta.org.crt
SSLCertificateKeyFile /usr/local/etc/apache22/ssl/bsd.b3ta.org.key
<filesmatch>
SSLOptions +StdEnvVars
</filesmatch>
BrowserMatch “.*MSIE.*” \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
CustomLog /var/log/httpd-ssl_request.log \
“%t %h %{SSL_PROTOCOL}x %{SSL_CIPHER}x \”%r\” %b”
strange enough. Httpd dies almost once a day especially when newsyslog runs. Turn off httpd log rotation from newsyslog will not eliminate the issue and httpd process will die randomly once a day. Switching back to Pound + mongrel rails cluster + RoR for now.
Lot of strange things happened to me these days; Half-dead lucent router and Crashing httpd.



