nginx:emerg:未知的“request_url”变量

Aja*_*pta 3 nginx digital-ocean ubuntu-18.04

我正在尝试在 Digital Ocean 的 Droplet 上的 Ubuntu 上配置 Nginx 服务器。

当我运行时sudo nginx -t,我收到错误

[emerg] unknown "request_url" variable还说了一些关于 etc/nginx/nginx.conf 文件的内容,但我没有看到下面文件中的任何地方使用了“request_url”。

这是我的default配置文件

# Enforce HTTPS
server {
    listen 80;
    listen [::]:80;
    return 301 https://$host$request_uri;
}

# Proxy all requests to Node
server {
    # Enable HTTP/2
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name api.storybook.space;

    # Use the Let's Encrypt certificates
    ssl_certificate /etc/letsencrypt/live/api.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/api.example.com/privkey.pem;

    # Include the SSL configuration from cipherli.st
    include snippets/ssl-params.conf;

    location / {
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-NginX-Proxy true;
        proxy_pass http://localhost:5000/;
        proxy_ssl_session_reuse off;
        proxy_set_header Host $http_host;
        proxy_cache_bypass $http_upgrade;
        proxy_redirect off;
    }
}
Run Code Online (Sandbox Code Playgroud)

我尝试寻找有关此问题的答案,但没有一个能解决我的问题。

谁能指出我正确的方向吗?

Aja*_*pta 7

成功了。

看起来这与缓存有关(可能不是正确的词)等。我创建了一个新的虚拟机并对其执行了相同的步骤。无论有无 SSL,均可完美运行。

以前,在设置此设置时,我不小心输入了$host$request_url一次$host$request_uri,从那以后我一直收到此错误

希望能帮助到你!