【问题标题】:Hostname in configfile of nginx unkown?nginx的配置文件中的主机名未知?
【发布时间】:2020-11-06 10:56:23
【问题描述】:

我正在 Linode Ubuntu 服务器上部署我的烧瓶应用程序。我在 YouTube 上使用 Corey Schafer 的 Flask 系列播放列表。但是我被困在我必须在 nginx 配置文件上设置以使 nginx 与 gunicorn 一起工作的部分。我的配置文件位于/etc/nginx/sites-enabled/flask,配置为:

server {
        listen 80;
        hostname ashkan-tools.de;

        location /static {
                alias /home/admin/flask/static;
        }

        location / {
                proxy_pass http://localhost:8000;
                include /etc/nginx/proxy_params;
                proxy_redirect off;
        }
}

ashkan-tools.de 是我已经与 Linode 名称服务器连接并设置 rDNS 的域。我已经尝试过www.ashkan-tools.de 甚至是 Linode 服务器的 IP。我使用sudo nginx -t -c /etc/nginx/nginx.conf从 nginx.conf 文件中得到了这个错误代码

nginx: [emerg] unknown directive "hostname" in /etc/nginx/sites-enabled/flask:3
nginx: configuration file /etc/nginx/nginx.conf test failed

每次我尝试使用 sudo service nginx restart 重新启动 nginx 服务时,都会收到以下错误代码:

Job for nginx.service failed because the control process exited with error code.
See "systemctl status nginx.service" and "journalctl -xe" for details.

我什至尝试使用sudo lsof -i:80 查看所有使用端口 80 的应用程序,但该命令没有显示任何内容。

【问题讨论】:

  • 您在哪里看到hostname 指令?它在 nginx 文档中吗?
  • 改成server_name

标签: python ubuntu nginx flask gunicorn


【解决方案1】:

nginx 没有hostname 指令!!改成server_name

nginx document for server_name

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-09
    • 2013-11-22
    • 1970-01-01
    • 1970-01-01
    • 2012-12-24
    • 2011-02-22
    • 2019-01-28
    相关资源
    最近更新 更多