Support / KnowledgeBase

 
Search the KnowledgeBase Search

Serving static content outside of your (gc) Django GridContainer

  • Applies to: (gs)

  • Difficulty: Easy

  • Time needed: 5 minutes

  • Tools needed: None

 

This article will guide you through the steps to configure your (gs) Grid-Service's Django Container to route static content such as html, images, and video files through the web nodes instead of using the Container's resources. This is recommended to do as it frees up the workload for your Container for things that need it. Using the Grid's web nodes to serve static content also makes better use of the many servers available in this clustered environment.

 

This article has the following dependencies:

  • If you currently do not have your Django GridContainer enabled you will need to have one in order to complete the steps in this article. You can add a container from within the AccountCenter.
  • Whenever installing Third-Party software please consult the official documentation. (mt) Media Temple does not support the installation and configuration of software not installed at time of service activation. For issues that fall outside of our Scope of Support, we recommend checking our User Forums and searching on Google for possible avenues of resolution.
  • mt-example.com and /home/#####/ are used as examples. Please be sure to replace this text with the proper information for your site or server.
  • GridContainer technology allows you to process frameworks such as Django or Ruby on Rails in an isolated environment. Make sure that you have RAM appropriate to the needs of your application. Not having enough resources can cause memory problems and instability in your application.

 

The recommended way to serve static content from the grid nodes is to symlink that content into the /home/#####/domains/app.mt-example.com/html directory.

For example, if there is a directory in your application that contains images/js/css, and it's physical path is:

/home/#####/containers/django/app/static_media 

And on your application's web pages, this content is referenced like this:

<link rel="stylesheet" href="/static_media/style.css"/> 


Then to serve the content from the grid nodes, run the following command:

ln -s /home/#####/containers/django/app/static_media /home/#####/domains/app.mt-example.com/html/static_media 


This causes the default rule (inserted by mtd generate_htaccess) in the .htaccess file to not proxy requests for those files.

If the path in your application's web pages is deeper than one directory, just create the intermediary directories in the domains/app.mt-example.com/html directory.  For example, if your content is referenced like this:

<link rel="stylesheet" href="/static_media/styles/default/style.css"/> 


Then you should do the following (one line at a time):


mkdir -p /home/#####/domains/app.mt-example.com/html/static_media/styles
ln -s /home/#####/containers/django/app/static_media /home/#####/domains/app.mt-example.com/html/static_media/styles/default 



Your static content should now be getting served through the Grid's clustered web nodes and your Django application will continue to work from inside the Container.

Notes/Supplemental Resources:

Revisions:


06-03-2008: Article Creation

User Comments

No visitor comments posted. Post a comment

Fields marked with an asterisk(*) are required. Comment on this article

Fill out the form below if you would like to comment on this article.
 
 
 

(code is not case-sensitive)
 
Submit
 
 

Continue