YoutubeDL-Material
YoutubeDL-Material copied to clipboard
[BUG] - Slight correct to documentation for the reverse proxy for nginx subfolder
Describe the bug In the documentation for a reverse proxy with a subfolder, it currenlty reads as:
location ~/ytdl(.*)$ {
rewrite /ytdl/(.*) / break;
proxy_pass http://example.com:8998;
}
location /api/ {
proxy_pass http://example.com:8998;
}
That partially works and yield a white screen when in effect. To actually get the full app, we need to add a $1 after the slash.
location ~/ytdl(.*)$ {
rewrite /ytdl/(.*) /$1 break;
proxy_pass http://example.com:8998;
}
location /api/ {
proxy_pass http://example.com:8998;
}
the rewwrite of /ytdl/(.*) / break writes everything after to ytdl/ straight to /, which doesn't work (IE ytdl/#/home gets mapped to /), what we want is to keep everything after the slash (IE we want /ytdl/#/home to get mapped to /#/home), hence the need for $1 after the rewrite
I adapted the config from this comment and all is working well. I could not get either of the above configs to work.
location /ytdl {
return 301 $scheme://$host/ytdl/;
}
location ^~ /ytdl/ {
proxy_pass http://127.0.0.1:8998;
proxy_redirect off;
proxy_set_header Referer '';
proxy_set_header Host 127.0.0.1:8998;
rewrite /ytdl(.*) $1 break;
}
location ^~ /ytdl/api/ {
proxy_pass http://127.0.0.1:8998;
}
location ^~ /api/ {
proxy_pass http://127.0.0.1:8998;
}
For me, the below config works (header access control allowed, otherwise only html code is displayed)
location /ytdl {
return 301 /ytdl/;
}
location ^~ /ytdl/ {
add_header Access-Control-Allow-Origin *;
proxy_pass http://127.0.0.1:8998;
proxy_redirect off;
proxy_set_header Referer '';
proxy_set_header Host 127.0.0.1:8998;
rewrite /ytdl(.*) $1 break;
}
location ^~ /ytdl/api/ {
proxy_pass http://127.0.0.1:8998;
}
location ^~ /api/ {
proxy_pass http://127.0.0.1:8998;
}
Hi! I came here after some clicks and the configuration suggested by @DuckieNukeEm works for me! Why the documentation has not been updated yet? I can do a PR if needed @Tzahi12345
For me, the below config works (header access control allowed, otherwise only html code is displayed)
location /ytdl { return 301 /ytdl/; } location ^~ /ytdl/ { add_header Access-Control-Allow-Origin *; proxy_pass http://127.0.0.1:8998; proxy_redirect off; proxy_set_header Referer ''; proxy_set_header Host 127.0.0.1:8998; rewrite /ytdl(.*) $1 break; } location ^~ /ytdl/api/ { proxy_pass http://127.0.0.1:8998; } location ^~ /api/ { proxy_pass http://127.0.0.1:8998; }
I am not a nginx expert but maybe you have add_header X-Content-Type-Options nosniff;
enabled somewhere