I have two sites in sites-enabled
for nginx
:
1) project
- this is essentially the top level domain - mysite.com
server {
listen 80;
location / {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /static {
alias /home/www/flask-deploy/project/static/;
}
}
2) blog
- this is for a blog, that is accessible via: mysite.com:8080
server {
listen 8080;
location blog/ {
proxy_pass http://localhost:8000;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
}
location /static {
alias /home/www/flask-deploy/blog/static/;
}
}
Nginx has accepted both configurations, but when I visit 1
i get all of the text, but no css, or images.
If I visit 2
i get everything working fine.
What am I doing wrong?
Thank you
For the
alias
directive to work correctly, the URI in thelocation
and the URI in thealias
directive should both end in/
or neither end in/
. The algorithm seems to substitute one string for the other.So you should probably write:
However, when the last element(s) of the alias match the location, the
root
directive is preferred (see this):Your
location blog/
looks incorrect, prefix locations should always begin with a/
.