plausible/docs

Proxy Plausible (selfhosted) with nginx not working

timscha opened this issue · 0 comments

Hello!
I hope that this is the right place to ask for help/talk about the documentation.
I tried to use the described proxy method with nginx as described here: https://plausible.io/docs/proxy/guides/nginx

But when trying to open https://mydomain2.de/js/script.js I only get an 404 error - when trying to open the url with the url where my selfhosted plausible instance is running, it's working/the script will be shown.

I added the additional lines of Step 1.5, except the ones which are duplicated.

That's my current nginx config:

    location = /js/script.js {
        # Change this if you use a different variant of the script
        proxy_pass https://plausible.mydomain.de/js/script.js;
        proxy_set_header Host plausible.mydomain.de;
        proxy_ssl_name plausible.mydomain.de;
        proxy_ssl_server_name on;
        proxy_ssl_session_reuse off;

        # Tiny, negligible performance improvement. Very optional.
        proxy_buffering on;

        proxy_cache jscache;
        proxy_cache_valid 200 6h;
        proxy_cache_use_stale updating error timeout invalid_header http_500;

        # Optional. Adds a header to tell if you got a cache hit or miss
        add_header X-Cache $upstream_cache_status;
    }

    location = /api/event {
        proxy_pass https://plausible.mydomain.de/api/event;
        proxy_set_header Host plausible.mydomain.de;
        proxy_buffering on;
        proxy_http_version 1.1;

        proxy_set_header X-Forwarded-For   $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
        proxy_set_header X-Forwarded-Host  $host;
        proxy_ssl_name plausible.mydomain.de;
        proxy_ssl_server_name on;
        proxy_ssl_session_reuse off;
    }