I have a custom nginx build for my project and everything works fine except I'm confused about serving static files using the same nginx server (below you can see my config file) recently tried to set root=/home/USERNAME/media/app/ and root= /home/USERNAME/.virtualenvs/medialaw; also created static only applications in control and pointed extra_info to my MEDIA_ROOT and STATIC_ROOT respectively but all things failed.

Can anyone help me with it, may be someone already faced such a challenge?

server {
    listen   MY_PORT;
    server_name USERNAME.webfactional.com;

    access_log /home/USERNAME/logs/user/nginx/app_access.log;
    error_log  /home/USERNAME/logs/user/nginx/app_error.log;

    root /home/USERNAME/.virtualenvs/medialaw;

   location /m {
        alias /home/USERNAME/media/app/media;

        if ($query_string) {
            expires max;

    location /s {
        alias /home/imanhodjaev/media/app/static;

        if ($query_string) {
            expires max;

    location / {
        proxy_pass_header Server;
        proxy_set_header Host $http_host;
        proxy_redirect off;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Scheme $scheme;
        proxy_connect_timeout 10;
        proxy_read_timeout 10;
        proxy_pass http://localhost:PORT/;

    error_page 500 502 503 504 /media/50x.html;



asked 12 Sep '12, 12:30

imanhodjaev's gravatar image

accept rate: 0%

edited 12 Sep '12, 13:22

The directives you have outlined should work, the location and alias directive together are what you want to use to bind a directory to a URI. You may want to submit a support ticket so we can look directly at the server and account.

permanent link

answered 12 Sep '12, 23:54

johns's gravatar image

johns ♦♦
accept rate: 23%

Thanks and they worked since I just removed static apps to serve my media and static files from Webfaction control panel,



(13 Sep '12, 11:55) imanhodjaev imanhodjaev's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 12 Sep '12, 12:30

question was seen: 1,849 times

last updated: 13 Sep '12, 11:55

Features & prices    Sign up    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
© Copyright 2003-2015 Swarma Limited - WebFaction is a service of Swarma Limited