First time here? Check out the FAQ!
0

How to serve images and other uploaded files with NGINX?

I have installed successfully the Askbot using CentOS 7 + PostgreSQL + Gunicorn + Nginx

But it won't shows any images you can check the url

http://139.59.24.83/questions/

my nginx configuration is

server {
        listen 80;
        server_name 127.0.0.1;

        location = /favicon.ico { access_log off; log_not_found off; }
        location /static/ {
            root /home/techbrown;
        }
location / {
            proxy_set_header Host $http_host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
            proxy_pass http://unix:/home/techbrown/techbrown.sock;
        }
}

Thanks @Evgeny for kind help.. :)

gopalraha's avatar
332
gopalraha
asked 2016-07-28 15:23:07 -0500
Evgeny's avatar
13.2k
Evgeny
updated 2016-07-29 02:21:44 -0500
edit flag offensive 0 remove flag close merge delete

Comments

add a comment see more comments

1 Answer

1

The following clause in the nginx server configuration will serve uploaded (or other static files):

 location /upfiles/ {   #or other location qualifier
    alias /some/directory/; #adjust to the path where the files are put
    autoindex off;
    expires 30d;
}

Please refer to the nginx documentation.

Evgeny's avatar
13.2k
Evgeny
answered 2016-07-29 02:20:33 -0500
edit flag offensive 0 remove flag delete link

Comments

Thanks for suggestions..

gopalraha's avatar gopalraha (2016-08-02 11:48:31 -0500) edit
add a comment see more comments