Ask Your Question

How to serve images and other uploaded files with NGINX?

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

gopalraha's avatar

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

Evgeny's avatar

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

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

my nginx configuration is

server {
        listen 80;

        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

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

Evgeny's avatar

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


Thanks for suggestions..

gopalraha's avatar gopalraha  ( 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


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

Seen: 17,942 times

Last updated: Jul 29 '16