私は、ドメインのためにこのようなnginxの設定を使用しtry_files:ジャンゴとnginxのは、サイトのルートページのために403
server_name_in_redirect off;
listen 80;
server_name ~^(www\.)?(.+)$;
root /var/www/$2/htdocs;
location/{
try_files $uri $uri/ $uri/index.htm @django;
index index.html index.htm;
}
location @django {
fastcgi_pass 127.0.0.1:8801;
fastcgi_param PATH_INFO $fastcgi_script_name;
fastcgi_param REQUEST_METHOD $request_method;
fastcgi_param QUERY_STRING $query_string;
fastcgi_param SERVER_NAME $server_name;
fastcgi_param SERVER_PORT $server_port;
fastcgi_param SERVER_PROTOCOL $server_protocol;
fastcgi_param CONTENT_TYPE $content_type;
fastcgi_param CONTENT_LENGTH $content_length;
fastcgi_pass_header Authorization;
fastcgi_intercept_errors off;
fastcgi_param REMOTE_ADDR $remote_addr;
}
DjangoのURLの設定:
urlpatterns = patterns('',
url(r'^$', home, name='home'),
url(r'index.htm', home, name='home'),
url(r'^(?P<name>.*).htm$', plain_page, name="plain_page"),
}
http://domain.com/somepage.htmのようなすべてのURLが常にhttp://domain.com/それ以外、良い作品Nginxによって403を示しています。
あなたはサイトのルートに静的index.htmファイルを追加する場合 - あなたは何の静的のindex.htmを持っていない場合、それが原因でtry_filesディレクティブ
の開かれていますが、http://domain.com/index.htmページを呼び出すには、それbufはジャンゴ
によって開かれますあなたは静的なindex.htmを持っておらず、http://domain.com/をオープンしていますが、アイデア index.htmを見て、try_filesチェーンの最後のdjangoに渡すべきです。
how to make http://domain.com/この場合、djangoのindex.htmを呼び出す必要がありますか?
ありがとうございました。私は何らかの方法でそれを解決し、私が覚えている限り、異なるアプローチを使用しました。 – Zelid