Category Archives: assets

Apache Directives for having two sites running on two servers on one domain

I hope the title is understandable. I have a site that uses a PHP framework and this other site that runs on a NodeJS framework. Right now, if you navigate to you will be on the NodeJS site. What I am trying to achieve is that if you go to you will be on the NodeJS site. Notice that it is just a path and there are no subdomains or ports seen (at least by the end user).

In the vhost file, I used an apache Location directive to try and achieve this, similar to the following.

<Location /foo>

The good news is that when I go to I am on the NodeJS site. However, all the static assets (such as CSS and JS) are being loaded from instead of (the Node site)? Short of rewriting all the links on the page to start with /foo, is there something I can tweak in the Apache rules to achieve this?

I found the Location directive in the Apache 2.2 docs, but not much rewriting links to these assets.

Apache only allow JPG files to be loaded

So I'm facing a strange situation. I setup a very small website, which loads all its assets with relative paths.

Now the problem is that only jpg files are loaded. I ran many tests to be sure about this. Every other asset (css, js, picture) return a 404 not found (all paths are correct), and when I try to access a subfolder it returns a 403 forbidden, even if the rights are set to 777.

I'm running this on an apache server with a nginx reverse proxy, but I have no possibility of editing its configuration. Now this website runs on a subdomain, and I have many other websites running on other subdomains, with no errors at all. And I have no .htaccess currently set.

Any solutions ? Thanks a lot !

edit I also tried to put absolute paths instead of relatives, still the same problem.

To access javascript files from another app

I'm trying to access to my pre-compiled files of my application from another. I've a specific architecture. Here is a simplified tree

├── app
│   ├── assets
│   │   ├── javascripts
│   │   │   ├──
│   │   │   ├──
├── my-other-app
│   ├── index.html
│   ├── javascript
│   │   ├── anotherJSFile.js

I would like to load on index.html the compiled file of

my-other-app isn't a Rails app. It contains a basic index.html file where a specific URL redirect where I try something like:

<script src=""></script>

I've defined it on an Apache configuration file (this part is ok).

My problem is that I can't find any way to access to a compiled my_js_file.js file. The access to the file and the file name itself (with fingerprint). How could I solve this?

Edit: I think the main problem comes from the fingerprint because I need to know it to adapt my url on my second app dynamically.

Edit2: I've found a way to generate dynamic url with correct fingerprint but I still can't access to compiled files (unauthorized)

Apache Reverse Proxy for Ruby’s Assets in different Servers

I have a Public IP address and a domain that points to a Virtual Server that hosts my web page: Lets say that this domain is

The Virtual Server that hosts this web page has Apache 2.4 and has the as internal IP address.

I have another Virtual server running a ruby on rails application with as internal IP address. I don't know if this is relevant or not, but the RoR application is serve by Passenger for apache.

Well, I want to access my RoR app with

With the proxy_html mod enabled and using the ProxyPass and ProxyPassReverse directives I CAN see to what I could call the "index" page of my app (authentication page).

The first problem here is that it seems that the server can't reach or find the images (assets), so this page is not shown properly.

Next, when I try to login with an existing user and a correct password, I get the "The requested URL /users/login was not found on this server." error message. Here you can see that the server is looking for /users/login instead of /app/users/login. The server is looking inside itself instead of looking in the server that is running the app.

If I add the route /users/login with the ProxyPass and ProxyPassReverse the server can reach the main page of my app. This fix does not seems to be the best to solve my issue, first of all because it still not showing the assets and second because if I want to enter to the management area of my user, the route is like /"user_name"/management, and again it can not find it, so in order to find it I need to add again a new line for each user. This seems ridiculous.

I have this in my configuration file for apache.

    ProxyRequests On
ProxyPass /app/ ProxyPassReverse /app/
ProxyPass /app/users/login/ ProxyPassReverse /app/users/login/

But it seems that is not right or is not enough.

Again, I can see just the pages that I have routed in my configuration file, just that. I can not go any further because it seems that my proxy server is not configured the right way.

Any help?

Yii2 Assets are not loading in case of .htaccess redirection

I am redirecting users from wildcard sub-domains to a specific sub directory using mod rewrite rule while not changing address bar url. I was able to do it but with some issues with my yii2 project. After redirecting no assets is loading. No CSS or JS, nothing. I am guessing this has something to do with relative paths of assets. How can I solve this problem? Do I need to change @webroot alias, if so how can I do that?

Some issues acessing asset files in production mode

I am using Ruby on Rails 4.1.1 and on my local machine I have the following image:

# Directory: MyApp/app/assets/images/

I upload MyApp using the Capistrano gem and all seems to work as expected. However when I try to access my website through the browser at the following URLs


then I get an error page:

The page you were looking for doesn't exist.
You may have mistyped the address or the page may have moved.

In the log file I get:

1) ActionController::RoutingError (No route matches [GET] "/logo.png"):
2) ActionController::RoutingError (No route matches [GET] "/assets/logo.png"):
3) ActionController::RoutingError (No route matches [GET] "/images/logo.png"):
4) ActionController::RoutingError (No route matches [GET] "/assets/images/logo.png"):

  actionpack (4.1.1) lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
  actionpack (4.1.1) lib/action_dispatch/middleware/show_exceptions.rb:30:in `call'
  railties (4.1.1) lib/rails/rack/logger.rb:38:in `call_app'
  railties (4.1.1) lib/rails/rack/logger.rb:20:in `block in call'
  activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `block in tagged'
  activesupport (4.1.1) lib/active_support/tagged_logging.rb:26:in `tagged'
  activesupport (4.1.1) lib/active_support/tagged_logging.rb:68:in `tagged'
  railties (4.1.1) lib/rails/rack/logger.rb:20:in `call'
  actionpack (4.1.1) lib/action_dispatch/middleware/request_id.rb:21:in `call'
  rack (1.5.2) lib/rack/methodoverride.rb:21:in `call'
  rack (1.5.2) lib/rack/runtime.rb:17:in `call'
  activesupport (4.1.1) lib/active_support/cache/strategy/local_cache_middleware.rb:26:in `call'
  rack (1.5.2) lib/rack/sendfile.rb:112:in `call'
  railties (4.1.1) lib/rails/engine.rb:514:in `call'
  railties (4.1.1) lib/rails/application.rb:144:in `call'
  railties (4.1.1) lib/rails/railtie.rb:194:in `public_send'
  railties (4.1.1) lib/rails/railtie.rb:194:in `method_missing'
  /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.45/lib/phusion_passenger/rack/thread_handler_extension.rb:74:in `process_request'
  /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.45/lib/phusion_passenger/request_handler/thread_handler.rb:141:in `accept_and_process_next_request'
  /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.45/lib/phusion_passenger/request_handler/thread_handler.rb:109:in `main_loop'
  /usr/local/rvm/gems/ruby-2.1.1/gems/passenger-4.0.45/lib/phusion_passenger/request_handler.rb:448:in `block (3 levels) in start_threads'

What is the problem and how can I solve it?

  • In my local machine (development mode) I do not have problems.
  • My remote machine runs Ubuntu 12.04 LTS, Phusion Passenger 4.0.45, Apache 2.2.22.