Django Nginx默认页面显示。无法获取要显示的应用程序
第一次使用Nginx的用户。正在尝试将Nginx连接到运行django应用程序的Gunicorn。该应用程序实际上还没有编写,所以一旦所有内容都配置好,它就会显示一个正在构建的页面 我似乎无法使Nginx配置正确地将请求传递给Gunicorn,然后再传递给Django。相反,它总是显示Nginx默认页面。非常感谢您的帮助 这里是/etc/nginx/sites available/mysite:Django Nginx默认页面显示。无法获取要显示的应用程序,django,nginx,ubuntu-16.04,gunicorn,Django,Nginx,Ubuntu 16.04,Gunicorn,第一次使用Nginx的用户。正在尝试将Nginx连接到运行django应用程序的Gunicorn。该应用程序实际上还没有编写,所以一旦所有内容都配置好,它就会显示一个正在构建的页面 我似乎无法使Nginx配置正确地将请求传递给Gunicorn,然后再传递给Django。相反,它总是显示Nginx默认页面。非常感谢您的帮助 这里是/etc/nginx/sites available/mysite: server { listen 80; #server_name <serve
server {
listen 80;
#server_name <server IP>;
server_name <mysite.com>;
location = /favicon.ico { access_log off; log_not_found off; }
location /static/ {
root /home/<my user acct>/<my app>/<my site>;
}
location / {
include proxy_params;
proxy_pass http://unix:/home/<my user acct>/<my app>/<my site>/<my site>.sock;
}
}
服务器{
听80;
#服务器名称;
服务器名称;
location=/favicon.ico{access\u log off;log\u not\u found off;}
位置/静态/{
根/主//;
}
地点/{
包括代理参数;
代理通行证http://unix:/home////.sock;
}
}
以下是/etc/nginx/sites available/default:
##
# You should look at the following URL's in order to grasp a solid understanding
# of Nginx configuration files in order to fully unleash the power of Nginx.
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
# Generally, you will want to move this file somewhere, and start with a clean
# file but keep this around for reference. Or just disable in sites-enabled.
#
# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples.
##
# Default server configuration
#
server {
listen 80 default_server;
listen [::]:80 default_server;
# SSL configuration
#
# listen 443 ssl default_server;
# listen [::]:443 ssl default_server;
#
# Note: You should disable gzip for SSL traffic.
# See: https://bugs.debian.org/773332
#
# Read up on ssl_ciphers to ensure a secure configuration.
# See: https://bugs.debian.org/765782
#
# Self signed certs generated by the ssl-cert package
# Don't use them in a production server!
#
# include snippets/snakeoil.conf;
root /var/www/html;
# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;
#server_name <mysite.com> <www.mysite.com>;
#server_name localhost;
server_name _;
#server_name <server IP>;
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ =404;
}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# include snippets/fastcgi-php.conf;
#
# # With php7.0-cgi alone:
# fastcgi_pass 127.0.0.1:9000;
# # With php7.0-fpm:
# fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
listen 443 ssl; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/<mysite.com>/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/<mysite.com>/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
# Virtual Host configuration for example.com
#
# You can move that to a different file under sites-available/ and symlink that
# to sites-enabled/ to enable it.
#
#server {
# listen 80;
# listen [::]:80;
#
# server_name example.com;
#
# root /var/www/example.com;
# index index.html;
#
# location / {
# try_files $uri $uri/ =404;
# }
#}
##
#你应该看看下面的网址,以便掌握一个坚实的理解
#为了充分发挥Nginx的威力,需要对Nginx配置文件进行修改。
# http://wiki.nginx.org/Pitfalls
# http://wiki.nginx.org/QuickStart
# http://wiki.nginx.org/Configuration
#
#通常,您会希望将此文件移动到某个位置,然后从一个干净的
#存档,但保留此文件以供参考。或者只是在启用的站点中禁用。
#
#请参阅/usr/share/doc/nginx doc/examples/了解更多详细示例。
##
#默认服务器配置
#
服务器{
监听80个默认_服务器;
侦听[:]:80默认_服务器;
#SSL配置
#
#侦听443 ssl默认_服务器;
#侦听[:]:443 ssl默认_服务器;
#
#注意:您应该为SSL通信禁用gzip。
#见:https://bugs.debian.org/773332
#
#阅读ssl_密码以确保安全配置。
#见:https://bugs.debian.org/765782
#
#ssl证书包生成的自签名证书
#不要在生产服务器中使用它们!
#
#包括snippets/snakeoil.conf;
root/var/www/html;
#如果您正在使用php,请将index.php添加到列表中
index.html index.htm index.nginx-debian.html;
#服务器名称;
#服务器名称localhost;
服务器名称;
#服务器名称;
地点/{
#首先尝试将请求作为文件提供,然后
#作为目录,然后返回显示404。
try_files$uri$uri/=404;
}
#将PHP脚本传递给FastCGI服务器,并在127.0.0.1:9000上侦听
#
#位置~\.php${
#包括snippets/fastcgi-php.conf;
#
##仅使用php7.0-cgi:
#fastcgi_pass 127.0.0.1:9000;
##使用php7.0-fpm:
#fastcgi_pass unix:/run/php/php7.0-fpm.sock;
#}
#拒绝访问.htaccess文件,如果Apache的文档根
#同意nginx的观点
#
#位置~/\.ht{
#否认一切;
#}
侦听443 ssl;#由Certbot管理
ssl_certificate/etc/letsencrypt/live//fullchain.pem;#由Certbot管理
ssl_certificate_key/etc/letsencrypt/live//privkey.pem;#由Certbot管理
include/etc/letsencrypt/options-ssl-nginx.conf;#由Certbot管理
ssl_dhparam/etc/letsencrypt/ssl-dhparams.pem;#由Certbot管理
}
#example.com的虚拟主机配置
#
#您可以将其移动到“可用站点/和符号链接”下的其他文件中
#到已启用的站点/以启用它。
#
#服务器{
#听80;
#听[:]:80;
#
#server_name example.com;
#
#root/var/www/example.com;
#index.html;
#
#地点/{
#try_files$uri$uri/=404;
# }
#}
我认为您应该删除可用站点中的默认配置,您的可用站点配置也应该在启用站点目录中
/sites-available/
|
|-> site.com
|-> site2.com
|-> disabled.com
/sites-enabled/ **this links to the files in /sites-available**
|
|-> site2.com
|-> site2.com
是的,我将我的/etc/sites available/mysite文件链接到/etc/sites enabled。删除默认配置文件是标准做法吗?基于此响应,我决定从sites enabled目录中删除指向默认配置的链接。这解决了问题。我在sites available目录中保留了默认配置。