Question

Unknown directive "proxy_pass"

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


Submit an answer

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!

Sign In or Sign Up to Answer

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.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

@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

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