How can I serve assets in /public that are not part of the asset pipeline with puma/nginx?

Question:

This is an AWS question, I’m using the Ruby 2.2 (Puma) platform.

My compiled assets (in /public/assets) are served as expected. The other assets in /public are not being served (404).

Where do I configure this? Is this an nginx problem? or a puma problem?

Or is this just an AWS image issue?

Here’s a live example (robots.txt should be served from the root):
http://staging.us-west-2.elasticbeanstalk.com/public/robots.txt

It’s also worth mentioning that the default Passenger platform image works out of the box.

Answer:

So, i’m using the exact same environment and I found the solution with a little google fu:

With rails 4+, in the file:

you should find the following lines near the top of the file

That’s all fine and dandy since we’re using passenger(nginx or apache), but Puma doesn’t handle this for us 🙂

To resolve this…

In your AWS console, go to your elastic beanstalk dashboard for the project in question, and click ‘Configuration’ on the left-hand menu.

Now click the little gear icon in the box titled ‘Software Configuration’

Now you should see a table under ‘Environment Properties’, enter ‘RAILS_SERVE_STATIC_FILES’ into a new field under ‘Property Name’, then type ‘true’ (without the quotes) into the value field, hit apply.

Viola! Now your project is serving static files 🙂

Leave a Reply