問題描述
nginx的配置文件中的主機名未知? (Hostname in configfile of nginx unkown?)
我正在 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: [emerg] unknown directive "hostname" in /etc/nginx/sites‑enabled/flask:3
nginx: configuration file /etc/nginx/nginx.conf test failed
從 nginx.conf 文件中得到了這個錯誤代碼
參考解法
方法 1:
nginx doesn't have hostname
directive!! change it to server_name
nginx document for server_name