Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

nginx: emerg: unknown "request_url" variable

I am trying to configure an Nginx Server on Ubuntu on a Droplet at Digital Ocean.

When I run sudo nginx -t, I am getting an error

[emerg] unknown "request_url" variable and also says something about the etc/nginx/nginx.conf file but I don't see "request_url" being used anywhere in the below file.

Here's my default config file

# 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;
    }
}

I've tried searching for answers about this, but none could solve my problem.

Can anyone please point me in the right direction?

like image 313
Ajay Avatar asked Jun 22 '26 02:06

Ajay


1 Answers

Got it working.

Looks like it was something to do with caching (may not be the right word), etc. I created a new VM and performed the same steps on it. Works perfectly with and without SSL.

Previously, while setting this up, I accidently entered $host$request_url instead of $host$request_uri once and since then I've been getting this error

Hope it helps!

like image 156
Ajay Avatar answered Jun 24 '26 05:06

Ajay