don't route certain requests through passenger for single virtual host

32 views
Skip to first unread message

Jay Howard

unread,
Aug 17, 2016, 12:37:20 PM8/17/16
to Phusion Passenger Discussions
I have a Rails application configured using a single Apache virtual host.  All requests to this virtual host go through Passenger and are served by Rails.

Is there a way to flag certain requests (to that virtual host) such that they are *not* handled by Passenger/Rails, and instead are served by Apache itself?

Goal is to reduce load on Rails by preventing it from having to serve these static files.

I realize that I could create a second named virtual host, but I don't have control over the clients and so can't force them to use a new host name for static resources.

Ideally I'd want to use some sort of path regexp to "opt out" certain requests from being served by Passenger/Rails.

Or is there some better way?

Daniel Knoppel

unread,
Aug 17, 2016, 6:13:32 PM8/17/16
to Phusion Passenger Discussions

Jay Howard

unread,
Aug 17, 2016, 10:42:03 PM8/17/16
to Phusion Passenger Discussions
Gah.  I didn't realize the "PassengerEnabled" directive could be used inside <Directory> blocks.  Sorry about that.

That said, I copied the example given and requests still seem to be getting sent to Passenger.  With the config below, when I request "https://myserver.mydomain.com/images/foobar.jpg", which doesn't exist, I get a RoutingError in my Rails logs.  We're on 4.0.59 if that matters.

Config:

<VirtualHost *:443>
  SSLEngine on
  SSLCertificateFile {EDITED}
  SSLCertificateKeyFile {EDITED}
  SSLCertificateChainFile {EDITED}
  SSLProtocol All -SSLv2 -SSLv3
  SSLHonorCipherOrder On
  SSLCipherSuite HIGH:!aNULL:!eNULL:!EXPORT:!DES:!MD5:!PSK:!RC4
  Header always set Strict-Transport-Security "max-age=63072000; includeSubdomains;"
  ServerName {EDITED}
  RewriteEngine on

  # limit to allowed methods
  RewriteCond %{REQUEST_METHOD} !^(GET|POST|HEAD|PUT|PATCH|DELETE)
  RewriteRule .* - [F,L]

  DocumentRoot "/websites/myapp/public"

  <Directory "/websites/myapp/public">
    Options FollowSymLinks
    AllowOverride None
    Order allow,deny
    Allow from all
    AddOutputFilterByType DEFLATE image/gif
    AddOutputFilterByType DEFLATE image/png
    AddOutputFilterByType DEFLATE image/jpeg
    AddOutputFilterByType DEFLATE image/jpg
  </Directory>

  <Directory "/websites/myapp/public/images">
    PassengerEnabled off
    AllowOverride All
  </Directory>

  <Location "/secure">
    SSLCACertificateFile {EDITED}
    SSLCACertificatePath {EDITED}
    SSLVerifyClient require
    SSLVerifyDepth 1
    SSLRequireSSL
    SSLRequire %{SSL_CLIENT_S_DN_O} eq "My Company Inc."
  </Location>

  PassengerHighPerformance on
  PassengerMaxInstancesPerApp 0
  PassengerMaxPoolSize 20
  PassengerPoolIdleTime 0
  PassengerMinInstances 10
  PassengerMaxRequests 500
  PassengerFriendlyErrorPages off
</VirtualHost>


--
You received this message because you are subscribed to a topic in the Google Groups "Phusion Passenger Discussions" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phusion-passenger/0Ph884RFrEI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phusion-passenger+unsubscribe@googlegroups.com.
To post to this group, send email to phusion-passenger@googlegroups.com.
Visit this group at https://groups.google.com/group/phusion-passenger.
To view this discussion on the web visit https://groups.google.com/d/msgid/phusion-passenger/deda951a-efa2-4e49-9ded-ba1a265584f8%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Jay Howard

unread,
Aug 18, 2016, 3:08:46 PM8/18/16
to Phusion Passenger Discussions
When I turned PassengerHighPerformance to "off" the "PassengerEnabled off" directive started working.  Now it's a question of which I want more:  PassengerHighPerformance, or having static content served by Apache instead of Rails.

Daniel Knoppel

unread,
Aug 19, 2016, 4:57:30 AM8/19/16
to Phusion Passenger Discussions, jho...@alumni.utexas.net
Thanks for the update.

I'm not sure how much speed the high performance option gave anyway, you might get a bigger speed bonus by upgrading to 5: https://www.phusionpassenger.com/library/install/apache/migrating/migrating_from_p4_to_p5.html.

- Daniel


On Thursday, August 18, 2016 at 9:08:46 PM UTC+2, Jay Howard wrote:
When I turned PassengerHighPerformance to "off" the "PassengerEnabled off" directive started working.  Now it's a question of which I want more:  PassengerHighPerformance, or having static content served by Apache instead of Rails.
Reply all
Reply to author
Forward
0 new messages