Ask Your Question
0

How to serve images and other uploaded files with NGINX?

asked 2016-07-28 15:23:07 -0600

updated 2016-07-29 02:21:44 -0600

Evgeny gravatar image

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.. :)

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-07-29 02:20:33 -0600

Evgeny gravatar image

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.

edit flag offensive delete link more

Comments

Thanks for suggestions..

gopalraha gravatar imagegopalraha ( 2016-08-02 11:48:31 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-07-28 15:23:07 -0600

Seen: 1,148 times

Last updated: Jul 29 '16