問題:基本的な「/about」と「/contact」を含むすべてのURLが私のランディングページに移動します
例:URL www.mydomain.comは完全に機能します(cssなどをロードします)が、アドレスバーにwww.mydomain.com/aboutと表示されていても、www.mydomain.com/aboutはwww.mydomain.comに移動します。
質問:すべてをdjangoに渡すようにnginxを構成するにはどうすればよいですか?
djangoを使用してローカルで作成したWebサイトをEC2インスタンスにデプロイしています。デフォルトのランディングページにアクセスできますが、他のページにアクセスできません。/ about、/ contactマッピングを含む基本的なサイトがありますが、それらにアクセスすると、ランディングページにリダイレクトされます。これは私のnginx構成と関係があると確信していますが、基本的なnginxチュートリアルを調べた後、私が欠けているものを把握しているとは思いません。
これがnginxのconfファイルです...
server {
listen 80;
server_name mydomain.com;
access_log /var/log/nginx/sample_project.access.log;
error_log /var/log/nginx/sample_project.error.log;
# https://docs.djangoproject.com/en/dev/howto/static-files/#serving-static-files-in-production
location /static/ { # STATIC_URL
alias /home/ubuntu/path/to/static/; # STATIC_ROOT
expires 30d;
}
location /media/ { # MEDIA_URL
alias /home/ubuntu/path/to/static/; # MEDIA_ROOT
expires 30d;
}
# I have also tried 'location ~* ^(.*?)$' and it had the same effect
location / {
include fastcgi_params;
fastcgi_pass 127.0.0.1:8080;
}
}
nginxチュートリアルなどを読んでいると、多くのことができることは理解できますが、djangoを介してすべての着信URLを処理したいと思います。