I have an nginx site config like:
server {
server_name mydomain.com;
root /home/app/public;
passenger_ruby /usr/bin/ruby2.7;
passenger_app_root /home/app;
passenger_enabled on;
passenger_user app;
passenger_max_request_queue_size 3360;
passenger_max_requests 3360;
...
}
home/app's directory structure something like is:
(rails app)
app/
controllers/
..etc
config/
..etc
public
favicon.ico
404.html
frontend/
index.html
12345.js
45678.js
some-picture.jpg
I am trying to make it so that:
- visiting
mydomain.comwill render the index file inpublic/frontend - any asset request will be served from
publicand then if it's not found, fallback topublic/frontend.. For example: a request tomydomain.com/favicon.icowill serve the favicon inpublic, and a request tomydomain.com/some-picture.jpgwill serve the jpeg inpublic/frontend.
...
When experimenting with a vanilla nginx config, I found that I could accomplish this by doing:
server {
server_name mydomain.com;
root /home/app/public;
location = / {
index /frontend/index.html;
}
location {
try_files $uri /frontend/$uri;
}
...
}
However it seems that once passenger is added to this mix, this no longer works...