steffan
steffan

Reputation: 169

nginx reverse proxy and static files

Question: How do I serve content from a proxy and static content from well just have nginx serve it up.

Background: Hello I'm setting up a really simple nginx application and for the most part it works but I'd like to better understand nginx what's going on. I've followed the documentation but in the real world I run into some weeds.

here's the config:

server {
        location / {
                include uwsgi_params;
                uwsgi_pass 127.0.0.1:8080;
        }
}

The above code works the thing is I have some static content that I'd just like nginx to serve w/o bothering to send that back to the proxy.

Directory structure:

/var/www/env/application/app/ <--this is the proxied location
/var/www/env/application/app/static <-- i'd like to just have nginx serve these files w/o the proxy.

When I edit my server settings and try to add:

location /static {
        root /var/www/env/application/app/static/;
}

everything breaks

What am I doing wrong here?

Upvotes: 0

Views: 1471

Answers (1)

user1600649
user1600649

Reputation:

You don't understand how root works. Look at the documentation again and then try to understand why it should be:

location /static {
    root /var/www/env/application/app;
}

Upvotes: 3

Related Questions