speedtest icon indicating copy to clipboard operation
speedtest copied to clipboard

Missing js and css when using a reverse Proxy in a subdirectory

Open sherlockedBBC opened this issue 3 years ago • 3 comments

Version: 0.5.3

I am using traefik as a reverse proxy in front of speedtest. traefik is configured to forward requests to example.com/speedtest/ to speedtest and strip the /speedtest/ prefix. To speedtest, it looks like it is simply hosted in a root directory.

When accessing the site the HTML is loaded but the icon, js, and CSS files are not loaded because the path is example.com/app.js and not example.com/speedtest/app.js. If I change the path manually in my browser I get a 200 response.

Github Issue

sherlockedBBC avatar Feb 09 '21 11:02 sherlockedBBC

Hi @sherlockedBBC,

Yeah you're right. That is a genuine, that should be relatively simple to fix. I'll give it a look some time and produce a fix.

Regards.

e7d avatar Feb 19 '21 09:02 e7d

Thanks @e7d.

In the meantime, is there a workaround? Trying the following in nginx, which normally works for sub-directories, didn't do the trick for me:

        location /speedtest {
                return 301 $scheme://$host/speedtest/;
        }

        location ^~ /speedtest/ {
                rewrite /speedtest(.*) $1 break;
                proxy_pass http://127.0.0.1:5080;
                client_max_body_size 256M;
        }

        if ($http_referer ~* /speedtest) {
                rewrite ^/(.*) /speedtest/$1? redirect;
        }

aniqueta avatar Apr 13 '21 00:04 aniqueta

Also need this. I was able to hack my way around it by doing this in NGINX but it ain't pretty and ain't what we want to do (YMMV):

location ~ "^/(ip|ping|run|config.json|(app|icons|worker)\..{8}\.(css|js|woff|woff2|ttf))$" {
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    auth_jwt_enabled off;
    gzip off;
    proxy_pass http://localhost:5080;
}

location /speed-test {
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $http_connection;
    auth_jwt_enabled off;
    gzip off;
    proxy_pass http://localhost:5080/;
}

JoshMcCullough avatar Aug 02 '22 13:08 JoshMcCullough