Search code examples
ruby-on-railsapachesocketsunixunicorn

Proxy Apache Load Balancers to a Unix Socket instead of a port


How can we do the below Nginx configuration in Apache?
Basically proxying to a Unix socket instead of a load balanced port.
I want that Unicorn handle the load balancing instead of Apache.

upstream unicorn_server {
  server unix:/home/prats/public_html/myapp/current/tmp/sockets/unicorn.sock
  fail_timeout=0;
}

server {
    ...
    ...
    ...
  location / {
    ...
    ...    
    # If you don't find the filename in the static files
    # Then request it from the unicorn server
    if (!-f $request_filename) {
      proxy_pass http://unicorn_server;
      break;
    }
    ...
    ...
  }
}

Solution

  • ProxyRequests Off

    ProxyPass /stylesheets/ !

    ProxyPass /javascripts/ !

    ProxyPass /images/ !

    ProxyPass / http://example.com:8080/

    ProxyPassReverse / http://example.com:8080/