mirror of
https://github.com/go-shiori/shiori.git
synced 2026-04-25 06:25:54 +03:00
[GH-ISSUE #883] Apache reverse proxy does not work for me #406
Labels
No labels
component:backend
component:builds
component:builds
component:extension
component:frontend
component:readability
database
database:mysql
database:postgres
database:sqlite
feature:ebooks
github_actions
good first issue
hacktoberfest
note:duplicate?
note:fixed?
note:out-of-scope?
os:windows
priority:high
priority:low
pull-request
resolution:as-intended
resolution:cant-reproduce
resolution:duplicate
resolution:fixed
resolution:wontfix
tag:TBD
tag:big-task
tag:help-wanted
tag:huge-data
tag:meta
tag:more-info
tag:next
tag:no-stale
tag:requires-migrations
tag:research
tag:security 🛡️
tag:stale
tag:waiting-for-assignee
type:bug
type:documentation
type:enhancement
type:meta
type:ux
user:cli
user:web
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/shiori#406
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @marioscube on GitHub (Apr 8, 2024).
Original GitHub issue: https://github.com/go-shiori/shiori/issues/883
Data
Describe the bug / actual behavior
Started shiori with:
shiori server --storage-directory /home/debian/shiori/dataI go to shiori in a browser http://localhost:8080 it works (I can login etc.)
I try to make a reverse proxy in apache2 virtualhosts
RewriteEngine on
RewriteRule ^/shiori$ /shiori/ [R]
ProxyPreserveHost On
ProxyRequests off
<Location /shiori/>
Require all granted
ProxyPass http://192.168.1.180:8080/
ProxyPassReverse http://192.168.1.180:8080/
</Location>Expected behavior
In a brwoser:
http://localost/shiori should give a shiori login screen
What i get
a white browser screen with "Shiori - Bookmarks Manager" in the tab
So I am forwarded to the right place, but something in the code refuses this.
What am I doing wrong?
Am I missing a setting?
@fmartingr commented on GitHub (Apr 8, 2024):
I'm not familiar with Apache2, but have you tried setting the
-webrootconfgiuration flag to/shiori?if you wouldn't mind when you have it ready and working can you submit a PR to add Apache2 sample configuration in the documentation same we did with nginx? It would be really appreciated.
@marioscube commented on GitHub (Apr 8, 2024):
Thank you for responding.
Adding --webroot /shiori
and changing virtualhost to:
ProxyPass http://192.168.1.180:8080/shiori
ProxyPassReverse http://192.168.1.180:8080/shiori
and browsing for http://192.168.1.180/shiori
gives:
while without --webroot
and original virtualhost
ProxyPass http://192.168.1.180:8080
ProxyPassReverse http://192.168.1.180:8080
http://192.168.1.180/shiori
gives: a white screen with a tab "Shiori - Bookmarks Manager"
But it never goes to login.
http://192.168.1.180:8080
I tried with ngnix-proxy-manager and pointed it at http://192.168.1.180:8080 and got the same white screen with correct tab in firefox
I hope the log tell you something.
@fmartingr commented on GitHub (Apr 13, 2024):
I believe you need to use the
--webroot /shioriand leave the apache configuration as:@marioscube commented on GitHub (Apr 13, 2024):
OK, some progress and some problems.
Shiori version 1.6.2 (build
ceb392d22e) at 2024-04-07T19:38:20ZI start shiori (with:
shiori server --webroot /shiori --storage-directory /home/debian/Docker/shiori/data
It now starts with http://192.168.1.180/shiori = progress
1 - I can add sites
2 - however archive view does not work (not found)
3 - I expect the data to be in /home/debianDocker/shiori/data (writable for user 1000) but that directory remains empty
4 - I find the data in /home/debian/.local/share/shiori
Something goes wrong here!
Shiori in Docker:
http://192.168.1.180/shiori
docker run -d
--name=shiori
-p 8080:8080
-e PUID=1000
-e PGID=1000
-e TZ=Europe/Amsterdam
-e SHIORI_DIR=/data
-e SHIORI_WEBROOT=/shiori
-v /home/debian/Docker/shiori/data:/data
ghcr.io/go-shiori/shiori
Gives a WHITE screen.
http://1902.168.1.180:8080
With the same docker container seems to work fine, however I want to access shiori with http:///shiori (not :8080)
What can I do to make it work?
@nliakm commented on GitHub (Apr 19, 2024):
I think the simpliest solution would be to spin up shiori and the reverse proxy together via docker.
You can use docker-compose for that and fill a
docker-compose.yamlwith following content:You need to create the
shiori-nginx.confinside/home/debian/Docker/shiori/:From the directory of the
docker-compose.yamlyou can simple run the 2 containers with:and the shiori should be accessible via http://<your_ip>/shiori
IMPORTANT Make sure that no other process on the machine (e.g. apache2) is listening on port 80, otherwise you will receive an error on starting the docker containers similar to docker: Error response from daemon: Bind for 0.0.0.0:80 failed: port is already allocated.
@marioscube commented on GitHub (Apr 19, 2024):
@nliakm
Thank you for your write-up of a possible solution. I really appreciate it.
However:
So this is beyond my level of coding.
What I try to achieve is that I can access all my Docker containers from a browser with a name. Therefore I need some reverse proxy rules (in apache2). But those simple rules do not seem to work for shiori. Bummer.
@fmartingr commented on GitHub (Apr 20, 2024):
Change the
HTTP_WEBROOTenvironment variable forSHIORI_HTTP_ROOT_PATH.Anything in the apache logs or Shiori logs? you should see the environment variable configuration on shiori boot, are all variables correct?
@marioscube commented on GitHub (Apr 20, 2024):
I start a shiori docker with:
docker run -d
--name=shiori
-p 8080:8080
-e PUID=1000
-e PGID=1000
-e TZ=Europe/Amsterdam
-e SHIORI_DIR=/data
-e SHIOR_HTTP_ROOT_PATH=/shiori
-v /home/debian/Docker/shiori/data:/data
ghcr.io/go-shiori/shiori
In apache i have these rules:
## ReverseProxy shiori ##
I start shiori from a browser with http://192.168.1.180/shiori/
The apache access log gives:
`192.168.1.107 - - [20/Apr/2024:11:58:38 +0200] "GET /shiori/ HTTP/1.1" 200 2300 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
192.168.1.107 - - [20/Apr/2024:11:58:38 +0200] "GET /assets/css/style.css HTTP/1.1" 404 425 "http://192.168.1.180/shiori/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
192.168.1.107 - - [20/Apr/2024:11:58:38 +0200] "GET /assets/js/vue.min.js HTTP/1.1" 404 426 "http://192.168.1.180/shiori/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
192.168.1.107 - - [20/Apr/2024:11:58:38 +0200] "GET /assets/js/url.min.js HTTP/1.1" 404 426 "http://192.168.1.180/shiori/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
192.168.1.107 - - [20/Apr/2024:11:58:38 +0200] "GET /assets/js/page/base.js HTTP/1.1" 404 425 "http://192.168.1.180/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
192.168.1.107 - - [20/Apr/2024:11:58:38 +0200] "GET /assets/js/page/home.js HTTP/1.1" 404 425 "http://192.168.1.180/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
192.168.1.107 - - [20/Apr/2024:11:58:38 +0200] "GET /assets/js/page/setting.js HTTP/1.1" 404 425 "http://192.168.1.180/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"
192.168.1.107 - - [20/Apr/2024:11:58:38 +0200] "GET /assets/js/component/dialog.js HTTP/1.1" 404 426 "http://192.168.1.180/" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"`
On my browserscreen I see this: (empty white screen)
http://192.168.1.180:8080 works
@marioscube commented on GitHub (Apr 20, 2024):
If, in a browser, I add login to the url (http://192.168.1.180/shiori/login)
I get this:

@nliakm commented on GitHub (Apr 20, 2024):
Understood.
How does your whole shiori vhost config looks like? Not quite familiar with apache2 but did you try to test without
These rules might mess it up.
@marioscube commented on GitHub (Apr 20, 2024):
@nliakm
Thank you for thinking with us to find a solution. I'm certain it's just around a corner. We just have to find that elusive corner.
this is just there to make sure I can either type http://url/shiori or http://url/shiori**/** (note the / trailing slash)
My vhosts looks like this:
<VirtualHost *:80>
< /VirtualHost>. (without a " " before the /)
@nliakm commented on GitHub (Apr 20, 2024):
I think the problem is about the trailing slashes. How about turning the rule around? You could still type both with that way.
Note I removed ALL trailing slashes (also in the proxyPass).
@marioscube commented on GitHub (Apr 20, 2024):
@nliakm
That gives the same white screen and an error 500
(Proxy Error
The proxy server could not handle the request
Reason: DNS lookup failure for: 192.168.1.180:8080login)
when I type http://url/shiori/login.
and when I change the virthost to:
ProxyPass http://192.168.1.180:8080/shiori
ProxyPassReverse http://192.168.1.180/shiori
I get a 404 page not found error.
There must be something we are missing.......
@nliakm commented on GitHub (Apr 20, 2024):
I use following command
serve --webroot /shiorion startup. So this could be missing on your side also.My setup is a little bit different but you should just add it at the end of the docker run command.
@marioscube commented on GitHub (Apr 20, 2024):
@nliakm
I used to start a docker container with
-e SHIORI_WEBROOT=/shiori
@fmartingr asked me to change this to
-e SHIOR_HTTP_ROOT_PATH=/shiori
(I spotted a type I made there, corrected it, but no difference. Still a white screen.)
If I start docker-shiori with both -e varables active: same effect, white screen with "Shiori - bookmark manager" in the tab.
http://192.168.1.180:8080 still works (gives an error and after OK I get the login screen)
Maybe that is the error 404 that I keep seeing? Bit not on screen.
@nliakm commented on GitHub (Apr 20, 2024):
http://192.168.1.180:8080/ works because with that you directly connect to the shiori docker container without going over apache2 reverse proxy.
What I meant was to run the shiori docker like this:
@marioscube commented on GitHub (Apr 20, 2024):
@nliakm
2 step forward 1 step back.
If I do exactly as you suggested I can login to shiori with http://192.168.1.180/shiori. Great, 1 step forward. I did not know this was possible.
If I try to use a saved bookmark it then shows the readable view. Another step forward.
However if I then try to view the Archive it shows this page:

The same happens if I save another bookmark and then try to view the archive. 1 step back.
I can see the data is saved where I expect to to be saved (date and time stamp). It is just NOT read...... I think.
If I try to login with http://192.168.1.180:8080 I get a white screen. Another step back?
EDIT: If I revert shiori to the previous container the old archive data seems to be corrupted.
EDIT2: this might have been an error I made in configuring shiori.
@nliakm commented on GitHub (Apr 21, 2024):
I tried your setup and it looks more like a bug than a configuration problem.

When clicking on View Archive you can see in the browser developer console the reason for the http 404 error:
Shiori tries to request
/bookmark/1/archive/fileand not/shiori/bookmark/1/archive/file. If you manually enter the full address (in my case http://192.168.178.2/shiori/bookmark/1/archive/file), you will be able to view the archive correctly.I'm not a developer myself, but I think the cause of the problem lies in this file:
https://github.com/go-shiori/shiori/blob/master/internal/view/archive.html
The archive will be rendered via iframe and is harcoded using the path starting with
/bookmarkSo if maybe the
$$.RootPath$$prefix would be added to the iframe (line 20) to render the site and the href (line 17) to correctly move back to the content page could solve the issue. But @fmartingr would be the best person to tell if I'm right or not.@marioscube commented on GitHub (Apr 22, 2024):
@nliakm
Thank you for figuring this out.
The thing is that reverse proxy with nginx seems to work (have not verified this, I do not use nginx). Have you verified this?
Interesting that this does not work with apache2.
@nliakm commented on GitHub (Apr 22, 2024):
I cannot tell. I run shiori inside kubernetes and use a subdomain shiori.mydomain.com instead of the /shiori route.
@marioscube commented on GitHub (Apr 22, 2024):
@nliakm
Do you use docker with shiori or native?
I think the developer and I have a different understanding of what a /webroot in docker with apache2 reverse proxy should be.
For me all shiori files should be relative to the /webroot used in apache reverse proxy. It looks like shiori is programmed different.
@marioscube commented on GitHub (Apr 25, 2024):
@nliakm
I decided to take your "route". I got some inspirations from audiobookshelf where the developer could not get http:///audiobookshelf to work and gave this as a workaround.
I run my own DNS (DNSmasq) on my LAN. So I put [192.168.1.180 shiori.lan] in the hosts file of the DNSmasq server.
In apache I now just need:
in the apache2 virtualhosts.conf
This works for shiori.lan but obviously not for 192.168.1.180/shiori
Problem not solved, but workaround is OK.
@stale[bot] commented on GitHub (May 25, 2024):
This issue has been automatically marked as stale because it has not had any activity for quite some time.
It will be closed if no further activity occurs.
Thank you for your contributions.
@marioscube commented on GitHub (May 29, 2024):
Problem not solved.
Topic should stay active.
@stale[bot] commented on GitHub (Jul 9, 2024):
This issue has been automatically marked as stale because it has not had any activity for quite some time.
It will be closed if no further activity occurs.
Thank you for your contributions.