Report this

What is the reason for this report?

Unknown directive "proxy_pass"

Posted on March 20, 2021

Hello,

This is my first droplet, using Ubuntu 20.04, and I’ve followed all the steps for setting up everything, but I get the error unknown directive “proxy_pass” in “/etc/nginx/sistes-enabled/my-website” when starting/restarting nginx. Is there a way to fix this?

Thanks



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi there,

I believe that the proxy_pass directive needs to be specified inside the location{} directive.

If this does not work, feel free to share your Nginx Server Block here so I could advise you further.

Regards, Bobby

@bobbyiliev thanks for the reply, bellow it’s my server configuration with the location directive.

Upon further inspection, running nginx -V I see no reference to the module ngx_http_proxy_module.

server {
    # Listen HTTPS
    listen 80;
    listen [::]:80;
    server_name grupovapo.com;

    # Static Root
    location / {
        root /home/primariu/grupo-vapo-admin;
    }

    # Strapi API
    location /api/ {
        rewrite ^/api/?(.*)$ /$1 break;
        proxy_pass http://strapi;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass_request_headers on;
    }

    # Strapi Dashboard
    location /dashboard {
        proxy_pass http://strapi/dashboard;
        proxy_http_version 1.1;
        proxy_set_header X-Forwarded-Host $host;
        proxy_set_header X-Forwarded-Server $host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header Host $http_host;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_pass_request_headers on;
    }
}

Best regards

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.