Hello,

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;
}

Thanks,

Sultan

asked 12 Sep '12, 12:30

imanhodjaev's gravatar image

imanhodjaev
32
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.

link

answered 12 Sep '12, 23:54

johns's gravatar image

johns ♦♦
4.1k28
accept rate: 23%

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

Thanks,

Sultan

(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

By RSS:

Answers

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

Tags:

×742
×274
×157
×24
×19

Asked: 12 Sep '12, 12:30

Seen: 974 times

Last updated: 13 Sep '12, 11:55

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited