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

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
gopalraha's avatar
332
gopalraha
asked 8 years ago
Evgeny's avatar
13.2k
Evgeny
updated 8 years ago

Comments

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.

To enter a block of code:

  • enter empty line after your previous text
  • paste or type the code
  • select the code and press the button above
Preview: (hide)
Evgeny's avatar
13.2k
Evgeny
answered 8 years ago
link

Comments

Thanks for suggestions..

gopalraha's avatar gopalraha (8 years ago)
see more comments