login community faq

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?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
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 Sep 12 '12 at 12:30

imanhodjaev's gravatar image

imanhodjaev
32

edited Sep 12 '12 at 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.

answered Sep 12 '12 at 23:54

johns's gravatar image

johns ♦♦
340427

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

Thanks,

Sultan

(Sep 13 '12 at 11:55) imanhodjaev imanhodjaev's gravatar image
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
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

Tags:

×643
×228
×127
×18
×17

Asked: Sep 12 '12 at 12:30

Seen: 540 times

Last updated: Sep 13 '12 at 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