shiori: Unable to host under subpath
I’m trying to host shiori on port 7777 and then proxy pass https://localhost/shiori/ to that port, but when I do using this nginx config:
location /shiori/ {
rewrite ^/shiori/(.*)$ /$1 break;
proxy_pass http://localhost:7777;
proxy_redirect http://localhost:7777/ $scheme://$host/shiori/;
}
I get this result:
This page isn’t working
And the URL shows:
Any ideas? Seems like shiori redirects to / (root).
Manually going to localhost/shiori/login brings up a broken login page, seemingly without both css, images, etc (can’t click on anything).
About this issue
- Original URL
- State: closed
- Created 6 years ago
- Reactions: 3
- Comments: 18 (5 by maintainers)
Commits related to this issue
- Initial support for subpath #39 — committed to go-shiori/shiori by RadhiFadlillah 5 years ago
- Fix: now cookie set per subpath #39 — committed to go-shiori/shiori by RadhiFadlillah 5 years ago
- fix login problem when shiori is served behind rev-proxy and subpath When shiori is served in subpath cookie in login page is stored with wrong path, i.e. when root is set to /shiori, cookie path is ... — committed to KarolBedkowski/shiori by KarolBedkowski 3 years ago
Guys, I’ve implemented this in 99d2793. To use it, config your proxy (in this example I use Caddy) like this :
Then run
shiori servewithwebrootflag set like this :By the way, the
webrootflag will change the entire API route to be prefixed with the specified root. For example, by running command above now the index is located inlocalhost:9000/shioriinstead oflocalhost:9000.proxy_redirectonly rewrites headers (eg Location), shiori redirects to /login, hence your should beproxy_redirect / $scheme://$host/shiori/;for the login page to redirect properly.However this will not work with assets requested directly eg /css/,/js/ etc unless a rewrite is used .eg. for
location ~ ^/(css|js|api)to /shiori/, which I don’t think would work well.The issue also applies to caddy if the proxy isn’t root, and a
rewrite tofor all request isn’t used. e.g.Possible fix: adding a webroot flag for server cmd so that it can be used for paths,
serve -webroot shiorithis would need changing of asset sources in html files + redirects to include the webroot variable.If anyone’s still interested, I think I found the source of the issue.
path.Jointrims the trailing slash if the path isn’t/(see aa339d7706ef42b977f574bb77dee1c2ee3a1734)PR #374 sent. As suggested by @davidnewhall, logging in on by default, but can be turned off with
--log=falseat the command-line if necessary.Fundamentally, access logs on web servers should never be disabled by default. Recommend log rotation by default.
Now if only we can get that fix into the codebase. 😃 cc @deanishe
I’m still having issues with this when using the docker image. After I login with
--webrootset the browser gets stuck in an infinite redirect loop.Reproduction case:
docker run -p 9000:9000 radhifadlillah/shiori:latest shiori serve -p 9000 --webroot /shioriIf I remove the
--webroot /shioriparameter then everything works as expected.Wow very nice this deserves a new release!
On Monday, October 7, 2019, Radhi notifications@github.com wrote:
– Raphael