I have a nginx + uwsgi website (using Flask for dynamic python pages). I would like to serve the homepage which is static directly through nginx and route everything else to uwsgi.
The following nginx configuration directives work well to serve the homepage through nginx and redirect a call to mysite.com/login to uwsgi:
location / {
root /var/www/mysite.com/static;
index index.html index.htm;
}
location /login {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3031;
}
But I can't find a way to generalize the second directive to catch all calls to mysite.com/something and direct them to uwsgi.
I tried the following which didn't work (get 404 for anything except calls to mysite.com):
location / {
root /var/www/mysite.com/static;
index index.html index.htm;
}
location /* {
include uwsgi_params;
uwsgi_pass 127.0.0.1:3031;
}
Any suggestions?
Try something like this
server {
...
root /var/www/mysite.com/static;
index index.html index.htm;
try_files $uri @uwsgi;
location @uwsgi{
include uwsgi_params;
uwsgi_pass 127.0.0.1:3031;
}
...
}
http://wiki.nginx.org/HttpCoreModule#try_files
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With