Code Monkey home page Code Monkey logo

Comments (24)

fmartingr avatar fmartingr commented on June 26, 2024

I'm not familiar with Apache2, but have you tried setting the -webroot confgiuration 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.

from shiori.

marioscube avatar marioscube commented on June 26, 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:

shiori server --webroot /shiori --storage-directory /home/debian/shiori/data

WARN[2024-04-08T23:30:32+02:00] SHIORI_HTTP_SECRET_KEY is not set, using random value. This means that all sessions will be invalidated on server restart. 
INFO[2024-04-08T23:30:32+02:00] Starting Shiori v1.6.2                       
INFO[2024-04-08T23:30:32+02:00] starting http server                          addr=":8080"
WARN[2024-04-08T23:32:07+02:00] 192.168.1.180 - VMBookworm [08/Apr/2024:23:32:07 +0200] "GET /shiori" 404 0 "" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" (1ms)  clientIP=192.168.1.180 dataLength=0 hostname=VMBookworm latency=1 method=GET path=/shiori referer= statusCode=404 userAgent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0"

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.

shiori server --storage-directory /home/debian/shiori/data

WARN[2024-04-08T23:42:18+02:00] SHIORI_HTTP_SECRET_KEY is not set, using random value. This means that all sessions will be invalidated on server restart. 
INFO[2024-04-08T23:42:18+02:00] Starting Shiori v1.6.2                       
INFO[2024-04-08T23:42:18+02:00] starting http server                          addr=":8080"
INFO[2024-04-08T23:42:42+02:00] 192.168.1.180 - VMBookworm [08/Apr/2024:23:42:42 +0200] "GET /" 200 5750 "" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" (2ms)  clientIP=192.168.1.180 dataLength=5750 hostname=VMBookworm latency=2 method=GET path=/ referer= statusCode=200 userAgent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0"

http://192.168.1.180:8080

shiori server --storage-directory /home/debian/shiori/data

WARN[2024-04-08T23:45:29+02:00] SHIORI_HTTP_SECRET_KEY is not set, using random value. This means that all sessions will be invalidated on server restart. 
INFO[2024-04-08T23:45:29+02:00] Starting Shiori v1.6.2                       
INFO[2024-04-08T23:45:29+02:00] starting http server                          addr=":8080"
INFO[2024-04-08T23:45:47+02:00] 192.168.1.180 - VMBookworm [08/Apr/2024:23:45:47 +0200] "GET /" 200 5750 "" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" (1ms)  clientIP=192.168.1.180 dataLength=5750 hostname=VMBookworm latency=1 method=GET path=/ referer= statusCode=200 userAgent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0"
INFO[2024-04-08T23:45:48+02:00] 192.168.1.180 - VMBookworm [08/Apr/2024:23:45:48 +0200] "GET /assets/css/style.css" 200 75851 "http://192.168.1.180:8080/" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" (4ms)  clientIP=192.168.1.180 dataLength=75851 hostname=VMBookworm latency=4 method=GET path=/assets/css/style.css referer="http://192.168.1.180:8080/" statusCode=200 userAgent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0"
INFO[2024-04-08T23:45:48+02:00] 192.168.1.180 - VMBookworm [08/Apr/2024:23:45:48 +0200] "GET /assets/js/vue.min.js" 200 93390 "http://192.168.1.180:8080/" "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0" (1ms)  clientIP=192.168.1.180 dataLength=93390 hostname=VMBookworm latency=1 method=GET path=/assets/js/vue.min.js referer="http://192.168.1.180:8080/" statusCode=200 userAgent="Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/115.0"
etc.

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.

from shiori.

fmartingr avatar fmartingr commented on June 26, 2024

I believe you need to use the --webroot /shiori and leave the apache configuration as:

ProxyPass http://192.168.1.180:8080/
ProxyPassReverse http://192.168.1.180:8080/

from shiori.

marioscube avatar marioscube commented on June 26, 2024

OK, some progress and some problems.
Shiori version 1.6.2 (build ceb392d) at 2024-04-07T19:38:20Z

I 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?

from shiori.

nliakm avatar nliakm commented on June 26, 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.yaml with following content:

# docker-compose.yaml
version: "3.8"

services:
  web:
    image: nginx:alpine
    restart: unless-stopped
    ports:
      - 80:80
    volumes:
      - /home/debian/Docker/shiori/shiori-nginx.conf:/etc/nginx/conf.d/default.conf:ro
  shiori:
    image: ghcr.io/go-shiori/shiori
    restart: unless-stopped
    command: ["serve", "--webroot", "/shiori"]
    environment:
      - SHIORI_DIR=/data
      - SHIORI_HTTP_ROOT_PATH=/shiori
    volumes:
      - /home/debian/Docker/shiori/data:/data

You need to create the shiori-nginx.conf inside /home/debian/Docker/shiori/:

server {
    listen       80;
    listen  [::]:80;
    server_name  localhost;

    location /shiori/ {
        proxy_pass http://shiori:8080/;
        proxy_set_header Host $host;
        proxy_set_header X-Real-IP $remote_addr;
    }

    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }
}

From the directory of the docker-compose.yaml you can simple run the 2 containers with:

docker-compose up -d

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.

from shiori.

marioscube avatar marioscube commented on June 26, 2024

@nliakm

Thank you for your write-up of a possible solution. I really appreciate it.
However:

  • I use apache on port 80 for other things
  • I barely understand apache and nginx not at all
  • I usually do not use composer for docker, but start my containers with "run".
    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.

from shiori.

fmartingr avatar fmartingr commented on June 26, 2024

Gives a WHITE screen.

Change the HTTP_WEBROOT environment variable for SHIORI_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?

from shiori.

marioscube avatar marioscube commented on June 26, 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 ##

    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>

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)

Screenshot 2024-04-20 at 11 54 43

http://192.168.1.180:8080 works

from shiori.

marioscube avatar marioscube commented on June 26, 2024

If, in a browser, I add login to the url (http://192.168.1.180/shiori/login)

I get this:
Screenshot 2024-04-20 at 12 59 50

from shiori.

nliakm avatar nliakm commented on June 26, 2024

@nliakm

Thank you for your write-up of a possible solution. I really appreciate it. However:

* I use apache on port 80 for other things

* I barely understand apache and nginx not at all

* I usually do not use composer for docker, but start my containers with "run".
  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.

Understood.

How does your whole shiori vhost config looks like? Not quite familiar with apache2 but did you try to test without

    RewriteEngine on
    RewriteRule ^/shiori$ /shiori/ [R]

These rules might mess it up.

from shiori.

marioscube avatar marioscube commented on June 26, 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.

RewriteEngine on
RewriteRule ^/shiori$ /shiori/ [R]

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>

    ServerName 192.168.1.180
    ServerAlias vmbookworm.lan

    ## ReverseProxy shiori ##

    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>


    ErrorLog ${APACHE_LOG_DIR}/LANIPv4_error.log
    CustomLog ${APACHE_LOG_DIR}/LANIPv4_access.log combined

   ## end ReverseProxy

< /VirtualHost>. (without a " " before the /)

from shiori.

nliakm avatar nliakm commented on June 26, 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).

    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>

from shiori.

marioscube avatar marioscube commented on June 26, 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.......

from shiori.

nliakm avatar nliakm commented on June 26, 2024

I use following command serve --webroot /shiori on 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.

from shiori.

marioscube avatar marioscube commented on June 26, 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)

Screenshot 2024-04-20 at 18 49 11

Maybe that is the error 404 that I keep seeing? Bit not on screen.

from shiori.

nliakm avatar nliakm commented on June 26, 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:

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 \
    serve --webroot /shiori

from shiori.

marioscube avatar marioscube commented on June 26, 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:
Screenshot 2024-04-20 at 22 55 12

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.

from shiori.

nliakm avatar nliakm commented on June 26, 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:
image
Shiori tries to request /bookmark/1/archive/file and 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 /bookmark

So 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.

from shiori.

marioscube avatar marioscube commented on June 26, 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.

from shiori.

nliakm avatar nliakm commented on June 26, 2024

I cannot tell. I run shiori inside kubernetes and use a subdomain shiori.mydomain.com instead of the /shiori route.

from shiori.

marioscube avatar marioscube commented on June 26, 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.

from shiori.

marioscube avatar marioscube commented on June 26, 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:

    ServerName vmshiori.lan

            ProxyPass /              http://192.168.1.180:8080/

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.

from shiori.

stale avatar stale commented on June 26, 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.

from shiori.

marioscube avatar marioscube commented on June 26, 2024

Problem not solved.

Topic should stay active.

from shiori.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.