2011-12-24 13 views
9

私はnginx + uwsgiのウェブサイトを持っています(動的なpythonページにはFlaskを使用しています)。 私は、直接nginxを介して静的なホームページを提供し、他のすべてをuwsgiにルーティングしたいと思います。nginxで静的なホームページを提供し、uwsgiを通して残ります

次nginxの設定ディレクティブは、nginxの経由ホームページにサービスを提供してuwsgiするmysite.com/loginするコールをリダイレクトするためによく働く:

location/{                                                 
    root /var/www/mysite.com/static;                                         
    index index.html index.htm;                                            
}                                                   

location /login {                                               
    include uwsgi_params;                                             
    uwsgi_pass 127.0.0.1:3031;                                            
} 

しかし、私は二ディレクティブを一般化する方法を見つけることができませんmysite.com/somethingへのすべての呼び出しをキャッチし、それらをuwsgiに誘導します。

私は(mysite.comへの呼び出しを除いて何のための404を取得する)動作しませんでした次のことを試してみました:

location/{                                                 
    root /var/www/mysite.com/static;                                         
    index index.html index.htm;                                            
}                                                   

location /* {                                               
    include uwsgi_params;                                             
    uwsgi_pass 127.0.0.1:3031;                                            
} 

任意の提案ですか?

答えて

10

は** try_filesを変更した後、この

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

+3

おかげのようなものを試してみてください** try_files $ URI $ uriの/ @uwsgi 'へディレクティブ;'それは魅力 – gws

+2

NBのように働きました! '$ uri /'は重要で、私の場合でも問題を解決しました(Dreamhost VPSのnginx 0.8.4) – velochy

関連する問題