【问题标题】:How can I set a nginx index page for the domain name using Django?如何使用 Django 为域名设置 nginx 索引页面?
【发布时间】:2018-06-17 13:24:12
【问题描述】:

我正在使用 Django 和 nginx 制作网站。(另外,uWSGI 和 AWS EC2...)

我已经为 IPv4 域设置了 nginx(http://123.45.67.89),所以我可以访问正确的索引页面。

但我不知道为什么我不能为域名(http://example.com)做到这一点!我可以访问 nginx 的“默认页面”(欢迎使用 nginx!)。

你能帮我做一个域名吗?

我的 Django 项目文件(根)是/home/ubuntu/proj/mysite

我的索引页在/home/ubuntu/proj/mysite/taxi/templates/taxi/index.html

我已经在 AWS Route 53 中设置了所有内容。

以下是我的/etc/nginx/sites-enabled/mysite

server {
    listen 80;
    server_name 123.45.67.89; #example

    #access_log  /var/log/nginx/log/mysite.access.log;

    location = /favicon.ico { access_log off; log_not_found off; }
    location /static/ {
        root /home/ubuntu/proj/mysite;
    }

    location / {
        root            /home/ubuntu/proj/mysite;
        index           /taxi/templates/taxi/index.html; #location of index page
        include         /home/ubuntu/proj/mysite/uwsgi_params;
        uwsgi_pass      unix:/run/uwsgi/mysite.sock;
    }
}

我不知道我给你展示什么来帮助我......

其实我不确定是不是nginx的问题。

【问题讨论】:

    标签: python django amazon-web-services nginx


    【解决方案1】:

    如果我正确理解了你的问题,那么......

    这不是 Django 或 Nginx 的问题,这与 DNS 有关。

    在本地,您可以通过编辑主机文件将任何域指向任何 IP(具体操作方式取决于您使用的操作系统)。但这只会对开发有用,其他任何人都无法使用。

    为了将公开可用的域指向公开可用的 IP,您需要拥有该域的所有权并使用 DNS 管理将该域指向该 IP。

    对于这个答案的含糊之处深表歉意,但 DNS 本身就是一个很大的领域,您的问题留下了很多未知数。

    【讨论】:

      猜你喜欢
      • 2016-12-08
      • 1970-01-01
      • 2010-11-14
      • 2010-10-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-01-18
      • 2016-04-16
      相关资源
      最近更新 更多