Add ActionController::Base.relative_url_root = "/app1" at the end of your config/environment.rb 1 ActionController::Base.relative_url_root = "/app1" application 1 (similar for the other two applications). This will force Rails to add the correct URL prefix.
If you do not want to ruin the Rails configuration, you could probably force Nginx to go through your entire resource folder until it finds the one you need, if I'm not mistaken, it could be archived as follows:
location /assets/ { try_files /app1/$uri /app2/$uri /app3/$uri; }
Note that you must have different file names for different applications. This is already the case if you use the resource pipeline everywhere, as it hashes file names.
UPD
You can also try Referer based routing:
location /assets/ { if ($http_referer ~* /app1) { rewrite ^(.*)$ app1/$1 break; } if ($http_referer ~* /app2) { rewrite ^(.*)$ app2/$1 break; } if ($http_referer ~* /app3) { rewrite ^(.*)$ app3/$1 break; } }
source share