BookStackApp / BookStack

A platform to create documentation/wiki content built with PHP & Laravel
https://www.bookstackapp.com/
MIT License
15.17k stars 1.9k forks source link

BookStack is not available to me from host machines on the network #3775

Closed Kostosso closed 2 years ago

Kostosso commented 2 years ago

Attempted Debugging

Searched GitHub Issues

Describe the Scenario

Good afternoon,

Help me to understand. Please!!!

I have a network 192.168.1.0/24 I have Ubuntu Server (192.168.1.230) Host (win 10) 192.168.1.120

Operating System: Ubuntu 22.04.1 LTS Kernel: Linux 5.15.0-48-generic Architecture: x86-64width: 64 bits; Product: Intel(R) Celeron(R) J4105 CPU @ 1.50GHz; size: 8GiB

I have Docker installed:

Client: Docker Engine - Community Version: 20.10.18 API version: 1.41 Go version: go1.18.6 Git commit: b40c2f6 Built: Thu Sep 8 23:11:43 2022 OS/Arch: linux/amd64 Context: default experimental: true

Server: Docker Engine - Community engine: Version: 20.10.17 API version: 1.41 (minimum version 1.12)

Portainer Community Edition 2.15.1

I installed BookStack linuxserver/docker-bookstackdocker 5 days ago (not latest version. Last update was 3 days ago). I used Stack file for installation. Here he is:


version: "2" services: bookstack: image: lscr.io/linuxserver/bookstack container_name: bookstack environment:

I get 2 bookstack and bookstack_db containers working.

I am trying to access 192.168.1.230:6875 from HOST. Instead, I get: "Can't access the site. Site 46.188.93.35 cannot connect."

Help me figure out why BookStack is not available to me from host machines on the network? I can't open it from any address on the network.

(I even wrote: iptables -t nat -A POSTROUTING -s 172.17.0.3 ! -d 192.168.1.1/24 -j MASQUERADE After that, the hostes of my network became available to me from the bookstack container.) But I still don’t see the BookStack from the network Help me please!!!

Exact BookStack Version

v22.09.1-ls42

Log Content

No response

PHP Version

No response

Hosting Environment

Ubuntu 22.04.1 LTS Kernel: Linux 5.15.0-48-generic

G0lfH0t3l commented 2 years ago

I am just using BookStack so not much experience yet.

Could it be the empty setting : _APPURL= ?

Update: Could there be a routing issue? The error contains the public IP 46.188.94.25 and not a private IP address.

Kostosso commented 2 years ago

I had BookStack installed on another similar computer. I decided to move the installation to a new one. In the past, everything worked fine (to tell the truth there was an older version - 2 years ago). I saved a Stack file from an old computer. There I did not specify the APP_URL= value. To tell the truth, I do not really understand what it means and what its format should be.

Address: - This is the network address of the room where I install BookStack. This is an external address. When accessing a private network address, a transition occurs to the external address of the entire subnet (the external address of the router). It is very strange. I don't understand where the internal network address translation to the external network.

G0lfH0t3l commented 2 years ago

I did specify the APP_URL when I did a fresh deploy of the stack.

Did you also moved some volumes to the new computer? Could they contain some old network information?

e.g. https://hub.docker.com/r/linuxserver/bookstack states that parameter environment variable is needed:

for specifying the IP:port or URL your application will be accessed on (ie. http://192.168.1.1:6875 or https://bookstack.mydomain.com

EDIT: When I use wget to from the Ubuntu server shell/cli to check for the base url it is connecting. Maybe this could be a check to see if the website is running at all.

I used: wget --spider sub.domain.tld you will have to use wget --spider 192.168.1.230:6875 I guess.

ssddanbrown commented 2 years ago

@Kostosso As suggested by @G0lfH0t3l, please could you set the APP_URL value. This should be the full base URL, including protocol, that you'd expect to access BookStack on, and a domain/IP that should resolve to the Bookstack host. Example: APP_URL=http://92.168.1.230:6875.

Without this set, BookStack will infer it's host name from the request, and then use that for redirects & URL generation. I'm guessing this is where the 46.188.93.35 is coming from.

Kostosso commented 2 years ago

Thank you all very much for your advice and help, but the situation is not resolved.

Here is what the stack file looks like:

```yaml --- version: "2" services: bookstack: image: lscr.io/linuxserver/bookstack container_name: bookstack environment: - PUID=1000 - PGID=1000 - APP_URL=http://192.168.1.230:6875 - DB_HOST=bookstack_db - DB_USER=bookstack - DB_PASSWORD=constant - DB_DATABASE=bookstackapp volumes: - /path/to/data:/config ports: - 6875:80 restart: unless-stopped depends_on: - bookstack_db bookstack_db: image: lscr.io/linuxserver/mariadb container_name: bookstack_db environment: - PUID=1000 - PGID=1000 - MYSQL_ROOT_PASSWORD=constant - TZ=Europe/Paris - MYSQL_DATABASE=bookstackapp - MYSQL_USER=bookstack - MYSQL_PASSWORD=constant volumes: - /path/to/data:/config restart: unless-stopped ```

This is iptables:

``` Chain PREROUTING (policy ACCEPT) target prot opt source destination DOCKER all -- 0.0.0.0/0 0.0.0.0/0 ADDRTYPE match dst-type LOCAL Chain INPUT (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination DOCKER all -- 0.0.0.0/0 !127.0.0.0/8 ADDRTYPE match dst-type LOCAL Chain POSTROUTING (policy ACCEPT) target prot opt source destination MASQUERADE all -- 172.17.0.0/16 0.0.0.0/0 MASQUERADE all -- 172.18.0.0/16 0.0.0.0/0 MASQUERADE tcp -- 172.17.0.2 172.17.0.2 tcp dpt:9443 MASQUERADE tcp -- 172.17.0.2 172.17.0.2 tcp dpt:8000 MASQUERADE tcp -- 172.18.0.3 172.18.0.3 tcp dpt:80 Chain Docker (2 references) target prot opt source destination RETURN all -- 0.0.0.0/0 0.0.0.0/0 RETURN all -- 0.0.0.0/0 0.0.0.0/0 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:9443 to:172.17.0.2:9443 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8000 to:172.17.0.2:8000 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:6875 to:172.18.0.3:80 ```

This is what it looks like

wget --spider 192.168.1.230:6875
Spider mode enabled. Check if remote file exists.
--2022-10-13 14:14:30-- http://192.168.1.230:6875/
Connecting to 192.168.1.230:6875... failed: Connection refused.

curl 192.168.1.230:6875
curl: (7) Failed to connect to 192.168.1.230 port 6875 after 0 ms: Connection refused

But on another machine - COMPLETELY similar with exactly the same stack file

Iptables:

``` Chain INPUT (policy ACCEPT) target prot opt source destination Chain OUTPUT (policy ACCEPT) target prot opt source destination DOCKER all -- 0.0.0.0/0 !127.0.0.0/8 ADDRTYPE match dst-type LOCAL Chain POSTROUTING (policy ACCEPT) target prot opt source destination MASQUERADE all -- 172.17.0.0/16 0.0.0.0/0 MASQUERADE all -- 172.18.0.0/16 0.0.0.0/0 MASQUERADE all -- 172.30.32.0/23 0.0.0.0/0 MASQUERADE tcp -- 172.30.32.6 172.30.32.6 tcp dpt:80 MASQUERADE tcp -- 172.17.0.2 172.17.0.2 tcp dpt:9000 MASQUERADE tcp -- 172.18.0.3 172.18.0.3 tcp dpt:80 MASQUERADE tcp -- 172.17.0.2 172.17.0.2 tcp dpt:8000 Chain Docker (2 references) target prot opt source destination RETURN all -- 0.0.0.0/0 0.0.0.0/0 RETURN all -- 0.0.0.0/0 0.0.0.0/0 RETURN all -- 0.0.0.0/0 0.0.0.0/0 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:4357 to:172.30.32.6:80 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:9000 to:172.17.0.2:9000 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:6875 to:172.18.0.3:80 DNAT tcp -- 0.0.0.0/0 0.0.0.0/0 tcp dpt:8000 to:172.17.0.2:8000 ```
wget --spider 192.168.1.133:6875
Robot mode enabled. Checking for the existence of a remote file.
--2022-10-13 17:13:49-- http://192.168.1.133:6875/
Connecting to 192.168.1.133:6875... connection established.
HTTP request sent. Waiting for response… 302 Found
Address: http://192.168.1.133:6875/login [jump]
Robot mode enabled. Checking for the existence of a remote file.
--2022-10-13 17:13:49-- http://192.168.1.133:6875/login
Connecting to 192.168.1.133:6875... connection established.
HTTP request sent. Waiting for response… 200 OK
Length: no data [text/html]
The deleted file exists and may contain additional
links, but recursion is disabled - does not load.

curl 192.168.1.133:6875
<!DOCTYPE html>
<html>
     <head>
         <meta charset="UTF-8" />
         <meta http-equiv="refresh" content="0;url='http://192.168.1.133:6875/login'" />

         <title>Redirecting to http://192.168.1.133:6875/login</title>
     </head>
     <body>
         Redirecting to <a href="http://192.168.1.133:6875/login">http://192.168.1.133:6875/login</a>.
     </body>

I just don't understand what could be the cause... and what can I check and fix!!!

ssddanbrown commented 2 years ago
Kostosso commented 2 years ago
  1. Response from 192.168.1.230: number of bytes=32 time<1ms TTL=64 Response from 192.168.1.230: number of bytes=32 time<1ms TTL=64 Response from 192.168.1.230: number of bytes=32 time<1ms TTL=64 Response from 192.168.1.230: number of bytes=32 time<1ms TTL=64

  2. Starting Nmap 7.92 ( https://nmap.org ) at 2022-10-13 22:43 Nmap scan report for 192.168.1.230 Host is up (0.00088s latency).

PORT STATE SERVICE 6875/tcp closed unknown MAC Address: 00:E0:8F:68:12:2B (Cisco Systems) Nmap done: 1 IP address (1 host up) scanned in 0.47 seconds

3. All devices are on the same peer-to-peer network. Physically connected to a single unmanaged router. The network is not divided into subnets. The server on which BookStack works normally is physically located on the same network. Connected to the same router and has the address 192.168.1.133. (I regret that I have to replace him. He does his job perfectly. And I don’t want to lose the Wiki, there is a lot of information ...

ssddanbrown commented 2 years ago

So based on that, looks like you can connect to the host but not on port 6875. I can't remember exactly how portainer works, especially with docker-compose files, and I'm not really familiar with iptables.

Kostosso commented 2 years ago

I found the reason why BookStack didn't work! I completely rearranged the Ubuntu server. Reinstalled Docker and Portainer. Installed BookStack (BookStack - Linuxserver.io version:- v22.09.1-ls44 Build-date:- 2022-10-13T18:12:14 02:00; Mariadb - Linuxserver.io version:- 10.6.9-r0-ls71 Build -date:- 2022-10-12T00:12:56 02:00 ) from the Stack file I have (with APP_URL specified). And everything worked great!!! The bookstack site is available on port 6875. You can create new entries!

After that I tried to restore the backup databases. ( BookStack - Linuxserver.io version:- v21.11-ls170 Build-date:- 2021-11-18T17:00:48 01:00 (v.21.11) Mariadb - Linuxserver.io version:- 10.5.13- r0-ls43 Build-date:- 2021-11-13T14:03:18 01:00) I did the backup of the database as follows: • in the bookstack_db container mysqldump -u bookstack -p bookstackapp > bookstack_backup.sql • in the bookstack container tar -czvf bookstack -files-backup.tar.gz

I restored the backup in the following way: • in the bookstack_db container mysql -u bookstack -p bookstackapp < ​​bookstack_backup.sql I specify psw • in a bookstack container tar -xvzf bookstack-files-backup.tar.gz

After recovery, I could go to 192.168.1.230:6875 but immediately an error occurs (Unknown error). You can try to log in again, but with the same results. If you restart the bookstack and bookstack_db containers, then the message "Cannot access the site" appears.

I killed the docker kill ** and docker rm ** containers and also deleted the bookstack_default network that is created when containers are deployed. However, when trying to install the bookstack again using the stack file, immediately when 192.168.1.230:6875 is accessed, the message “Cannot access the site” appears and nothing more can be done.

Therefore, the reason for the denied access is an attempt to restore a backup copy of the data from old version.

Tell me please. How can I fix this error. It is probably necessary to update the original database to the current version and then make a backup. Or maybe there are other ways.

Thanks in advance.

ssddanbrown commented 2 years ago

Therefore, the reason for the denied access is an attempt to restore a backup copy of the data from old version.

When restoring, you need to ensure you restore into an empty database first. If you restore into a new instance, that's had it's database structure already created, you'll have problems. From that point on, the container will migrate the data upon startup. This means you should not start the bookstack container at all until you've restored your database. So generally:

Kostosso commented 2 years ago

Alas, I have not found a solution to this problem. I reinstalled the system again and BookStack works fine on a clean system. I decided not to waste any more time and in 4 hours I copied / pasted all the most necessary records from the old server to the new one. Horror! But it turned out to be a faster way.

I hope someone finds a solution to this problem. I would really like to know him.

Thanks to everyone who tried to help solve this problem.