Score:0

Reverse proxy failing with unknown error

gb flag

I'm trying to self host plausible analytics. So far I've installed docker, and started the docker containers. I've also ensured nginx is running, has a valid config, allowed ports 80 and 443 through ufw, and configured nginx with the domain: https://plausible.example.com.

My nginx config looks like this:

   server {
    server_name plausible.example.com;

    location / {
        proxy_pass http://localhost:8000;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    }

    listen [::]:443 ssl; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/plausible.example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/plausible.example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot

}

 server {
    if ($host = plausible.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    server_name plausible.example.com;

    listen 80;
    listen [::]:80;
    return 404; # managed by Certbot 
}

The problem is when I try to visit plausible.example.com I get a 502 bad gateway error. When I check the nginx error logs I get this error:

[error] 935230#935230: *579224 recv() failed (104: Unknown error) while reading response header from upstream

I've tried to find a solution to this error but I haven't been able too. Any help would be appreciated. Thanks.

Edit: I should also add that in the plausible env variables, the host name is: https://plausible.example.com

us flag
Does the Plausible server run in HTTP or HTTPS mode at port 8000? One reason for the error might be that it is running HTTPS, and you have configured HTTP as the protocol.
user avatar
gb flag
The plausible server only runs on http
us flag
What are the contents of nginx `error.log` and Plausible logs?
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.