pythondjangonginxstatic-pages

Wrong path in nginx to static page


Although I have the application in django, I want to set up a static page. Using nginx. But I get an error:

[alert] 100983#0: *439266 "/path_to_page_on_server/press_page.htmlindex.html" is not a directory,

Here is my url: url(r'^press/', TemplateView.as_view(template_name='press_page.html'), name='press')

Here is my config in nginx include:

location /press/ { alias /path_to_page_on_server/press_page.html; }

I would like to under /press/ have page press_page.html.


Solution

  • In nginx, your index value is set as index.html hence it is being appened to the alias-ed location.

    You need to specify the index to your custom file, and also drop the file reference in alias:

    location /press/ {
        alias /path_to_page_on_server/;
        index press_page.html index.html;
    }
    

    The last index.html is just a fallback, you can drop/replace it if you want.