在nginx上运行django时提供testpage

时间:2017-04-27 15:38:54

标签: python django ubuntu nginx

enter image description here

我正在通过https://serversforhackers.com/video/letsencrypt-for-free-easy-ssl-certificateshttps://certbot.eff.org/docs/intro.html,尝试将ssl证书添加到我的网站(ubuntu 16.04上的nginx上的django 1.8)。我希望能够从我的服务器提供测试页面。我的nginx文档根位于/ var / www / html。

deploy@server:/var/www$ ll html/
total 40
drwxr-xr-x 3 root root  4096 Apr 26 21:17 ./
drwxr-xr-x 3 root root  4096 Apr 25 16:27 ../
drwxrwxrwx 2 root root  4096 Apr 27 11:16 .well-known/
-rw-r--r-- 1 root root 11321 Jun 21  2016 index.html
-rw-r--r-- 1 root root   612 Feb  6 16:43 index.nginx-debian.html
-rw-r--r-- 1 root root 11321 Apr 26 21:17 test.html

nginx有2个配置文件。第一个是默认值,并具有以下位置块:

    location ~ /.well-known {
            allow all;
    }
    location ~ /.well-known/acme-challenge/ {
            allow all;
    }

第二个是:

# configuration file /etc/nginx/sites-enabled/example:
server {
    #listen 80;
    listen 80  ;
    listen [::]:80  ;
    listen 443 ssl http2  ;
    listen [::]:443 ssl http2  ;


    server_name  example.org www.example.org;
    include snippets/ssl-example.org.conf;
    include snippets/ssl-params.conf;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/deploy/example3;
    }

    location / {
        include         uwsgi_params;
        uwsgi_pass      unix:/run/uwsgi/example.sock;
    }

location ~* (?:^|/)\.  {
    allow all;
}

location ^~ /\.well-known {
            allow all;
    }

我希望能够使用以下方式提供测试页面:

http://example.com/test.html

相反,我得到上面的截图。如何配置nginx或django以允许提供测试页?

1 个答案:

答案 0 :(得分:0)

我认为问题不在于nginx配置,而是在r'^test.html$'配置中。根据屏幕截图,您尚未配置与您尝试访问的网址匹配的网址格式public class Utilities { public static final String FILE_EXTENSION = ".bin"; public static boolean saveNote(Context context, Notes notes){ String fileName = String.valueOf(notes.getDateTime()) + FILE_EXTENSION;

您可以在Django documentation中找到有关配置网址的详细信息。