How to setup with multiple reversed proxies? #3561
-
Hello, I've been trying to play around and self-host Plasubile, but I keep running into issues. I cannot download the script from my Next app. The setup is like this:
My Nginx conf: server {
listen 80 ;
listen [::]:80 ;
server_name myserver.com www.myserver.com;
return 301 https://$server_name$request_uri;
}
server {
server_name www.myserver.com myserver.com;
client_max_body_size 0;
location / {
# reverse proxy for next
proxy_pass http://localhost:3000;
proxy_http_version 1.1;
proxy_read_timeout 60;
proxy_connect_timeout 60;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
location /analytics/plausible {
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_read_timeout 60;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host https://myserver.com/anonymous-analytics/plausible;
proxy_ssl_name https://myserver.com/anonymous-analytics/plausible;
proxy_ssl_server_name on;
proxy_ssl_session_reuse off;
}
} And then my Next script tag: <Script
defer
data-domain="myserver.com"
data-api="/analytics/plausible"
src="/analytics/plausible/js/script.js"
/> As I mentioned, the problem is I cannot access the /script/js. I get an error of 400. I looked at the documentation, but mine is a bit specific case since I am self-hosting with multiple reversed proxies. What am I doing wrong? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 1 reply
-
Although not the best solution I managed to fix the script by adding a singular static file to my FS and adding that to the NGinx config. Not ideal, but works.... However now that requests do get sent, they all fail with code 400. |
Beta Was this translation helpful? Give feedback.
-
The requests most likely go to |
Beta Was this translation helpful? Give feedback.
-
I solved it. It had a couple of problems, but @ruslandoga you helped me go in the right direction 💪 First of the location url has to end with a / so that it recognizes like a directory and not a file. location /analytics/plausible/ { # forgot trailing slash
rewrite ^/analytics/plausible/(.*) /$1 break; # added rewrite to chop of /analytics/plausible part
proxy_pass http://127.0.0.1:8000;
proxy_http_version 1.1;
proxy_read_timeout 60;
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_cache_bypass $http_upgrade;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host; # this just needs the base url of the host not the whole proxy url
proxy_ssl_name $host; # this just needs the base url of the host not the whole proxy url
proxy_ssl_server_name on;
proxy_ssl_session_reuse off;
} Tyvm for the help 😎 |
Beta Was this translation helpful? Give feedback.
I solved it. It had a couple of problems, but @ruslandoga you helped me go in the right direction 💪
First of the location url has to end with a / so that it recognizes like a directory and not a file.