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

App breaks when appending a path to the APP_URL #3492

Closed stevenmasci closed 2 years ago

stevenmasci commented 2 years ago

Attempted Debugging

Searched GitHub Issues

Describe the Scenario

Hi, I'd like to host BookStack at https://app.mydomain.com/knowledge so I've entered this path as the APP_URL env var, however when I visit the site the styles fail to load and I get page not found, the console logs broken requests (screenshot below).

I can replicate this with the default configuration by changing the APP_URL in docker-compose.yml to APP_URL: http://localhost:${DEV_PORT:-8080}/knowledge

image

I've tried running php artisan bookstack:update-url to update the APP_URL and php artisan cache:clear. I might be miss understanding how the APP_URL environment field works?

Thanks for your help.

Exact BookStack Version

v22.04.2

Log Content

``` docker-compose up Creating network "bookstack_default" with the default driver Creating bookstack_node_1 ... done Creating bookstack_mailhog_1 ... done Creating bookstack_app_1 ... done Creating bookstack_db_1 ... done Attaching to bookstack_node_1, bookstack_app_1, bookstack_db_1, bookstack_mailhog_1 app_1 | DB_PASSWORD=bookstack-test app_1 | MAIL_PORT=1025 app_1 | MAIL_DRIVER=smtp app_1 | HOSTNAME=5fe505229743 app_1 | PHP_VERSION=8.1.6 app_1 | APACHE_CONFDIR=/etc/apache2 app_1 | PHP_INI_DIR=/usr/local/etc/php app_1 | GPG_KEYS=528995BFEDFBA7191D46839EF9BA0ADA31CBD89E 39B641343D8C104B2B146DC3F9C39DC0B9698544 F1F692238FBC1666E5A5CCD4199F9DFEF6FFBAFD app_1 | PHP_LDFLAGS=-Wl,-O1 -pie app_1 | PWD=/app app_1 | APACHE_DOCUMENT_ROOT=/app/public app_1 | DB_PORT=3306 app_1 | HOME=/root app_1 | TEST_DATABASE_URL=mysql://bookstack-test:bookstack-test@db/bookstack-test app_1 | APP_URL=http://localhost:8080/knowledge app_1 | PHP_SHA256=da38d65bb0d5dd56f711cd478204f2b62a74a2c2b0d2d523a78d6eb865b2364c app_1 | PHPIZE_DEPS=autoconf dpkg-dev file g++ gcc libc-dev make pkg-config re2c app_1 | DB_USERNAME=bookstack-test app_1 | DB_CONNECTION=mysql app_1 | DB_HOST=db app_1 | PHP_URL=https://www.php.net/distributions/php-8.1.6.tar.xz app_1 | SHLVL=1 app_1 | PHP_CFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 app_1 | APACHE_ENVVARS=/etc/apache2/envvars app_1 | PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin app_1 | MAIL_HOST=mailhog app_1 | DB_DATABASE=bookstack-dev app_1 | PHP_ASC_URL=https://www.php.net/distributions/php-8.1.6.tar.xz.asc app_1 | PHP_CPPFLAGS=-fstack-protector-strong -fpic -fpie -O2 -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 app_1 | _=/usr/bin/env db_1 | 2022-06-10 05:54:40+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1debian10 started. mailhog_1 | 2022/06/10 05:54:40 Using in-memory storage mailhog_1 | 2022/06/10 05:54:40 [SMTP] Binding to address: 0.0.0.0:1025 mailhog_1 | 2022/06/10 05:54:40 Serving under http://0.0.0.0:8025/ mailhog_1 | [HTTP] Binding to address: 0.0.0.0:8025 mailhog_1 | Creating API v1 with WebPath: mailhog_1 | Creating API v2 with WebPath: app_1 | Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( db_1 | 2022-06-10 05:54:40+00:00 [Note] [Entrypoint]: Switching to dedicated user 'mysql' db_1 | 2022-06-10 05:54:40+00:00 [Note] [Entrypoint]: Entrypoint script for MySQL Server 8.0.29-1debian10 started. db_1 | 2022-06-10T05:54:41.189588Z 0 [Warning] [MY-010918] [Server] 'default_authentication_plugin' is deprecated and will be removed in a future release. Please use authentication_policy instead. db_1 | 2022-06-10T05:54:41.189646Z 0 [System] [MY-010116] [Server] /usr/sbin/mysqld (mysqld 8.0.29) starting as process 1 db_1 | 2022-06-10T05:54:41.210579Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started. db_1 | 2022-06-10T05:54:41.746749Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended. db_1 | 2022-06-10T05:54:42.243735Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed. db_1 | 2022-06-10T05:54:42.243838Z 0 [System] [MY-013602] [Server] Channel mysql_main configured to support TLS. Encrypted connections are now supported for this channel. db_1 | 2022-06-10T05:54:42.249291Z 0 [Warning] [MY-011810] [Server] Insecure configuration for --pid-file: Location '/var/run/mysqld' in the path is accessible to all OS users. Consider choosing a different directory. db_1 | 2022-06-10T05:54:42.393740Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Bind-address: '::' port: 33060, socket: /var/run/mysqld/mysqlx.sock db_1 | 2022-06-10T05:54:42.394410Z 0 [System] [MY-010931] [Server] /usr/sbin/mysqld: ready for connections. Version: '8.0.29' socket: '/var/run/mysqld/mysqld.sock' port: 3306 MySQL Community Server - GPL. node_1 | node_1 | up to date, audited 143 packages in 2s node_1 | node_1 | 32 packages are looking for funding node_1 | run `npm fund` for details node_1 | node_1 | found 0 vulnerabilities node_1 | npm notice node_1 | npm notice New minor version of npm available! 8.9.0 -> 8.12.1 node_1 | npm notice Changelog: node_1 | npm notice Run `npm install -g npm@8.12.1` to update! node_1 | npm notice node_1 | rebuilt dependencies successfully app_1 | > @php -r "!file_exists('bootstrap/cache/services.php') || @unlink('bootstrap/cache/services.php');" app_1 | Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( app_1 | Installing dependencies from lock file (including require-dev) app_1 | Verifying lock file contents can be installed on current platform. app_1 | Nothing to install, update or remove app_1 | Package swiftmailer/swiftmailer is abandoned, you should avoid using it. Use symfony/mailer instead. app_1 | Generating optimized autoload files node_1 | node_1 | > watch node_1 | > npm-run-all --parallel build:*:watch node_1 | node_1 | node_1 | > build:css:watch node_1 | > sass ./resources/sass:./public/dist --watch node_1 | node_1 | node_1 | > build:js:watch node_1 | > chokidar --initial "./resources/**/*.js" -c "npm run build:js:dev" node_1 | node_1 | add:resources/js/app.js node_1 | add:resources/js/components/add-remove-rows.js node_1 | add:resources/js/components/ajax-delete-row.js node_1 | add:resources/js/components/ajax-form.js node_1 | add:resources/js/components/attachments-list.js node_1 | add:resources/js/components/attachments.js node_1 | add:resources/js/components/auto-suggest.js node_1 | add:resources/js/components/back-to-top.js node_1 | add:resources/js/components/book-sort.js node_1 | add:resources/js/components/chapter-toggle.js node_1 | add:resources/js/components/code-editor.js node_1 | add:resources/js/components/code-highlighter.js node_1 | add:resources/js/components/collapsible.js node_1 | add:resources/js/components/confirm-dialog.js node_1 | add:resources/js/components/custom-checkbox.js node_1 | add:resources/js/components/details-highlighter.js node_1 | add:resources/js/components/dropdown-search.js node_1 | add:resources/js/components/dropdown.js node_1 | add:resources/js/components/dropzone.js node_1 | add:resources/js/components/editor-toolbox.js node_1 | add:resources/js/components/entity-permissions-editor.js node_1 | add:resources/js/components/entity-search.js node_1 | add:resources/js/components/entity-selector-popup.js node_1 | add:resources/js/components/entity-selector.js node_1 | add:resources/js/components/event-emit-select.js node_1 | add:resources/js/components/expand-toggle.js node_1 | add:resources/js/components/header-mobile-toggle.js node_1 | add:resources/js/components/homepage-control.js node_1 | add:resources/js/components/image-manager.js node_1 | add:resources/js/components/image-picker.js node_1 | add:resources/js/components/index.js node_1 | add:resources/js/components/list-sort-control.js node_1 | add:resources/js/components/markdown-editor.js node_1 | add:resources/js/components/new-user-password.js node_1 | add:resources/js/components/notification.js node_1 | add:resources/js/components/optional-input.js node_1 | add:resources/js/components/page-comments.js node_1 | add:resources/js/components/page-display.js node_1 | add:resources/js/components/page-editor.js node_1 | add:resources/js/components/page-picker.js node_1 | add:resources/js/components/permissions-table.js node_1 | add:resources/js/components/popup.js node_1 | add:resources/js/components/setting-app-color-picker.js node_1 | add:resources/js/components/setting-color-picker.js node_1 | add:resources/js/components/shelf-sort.js node_1 | add:resources/js/components/sidebar.js node_1 | add:resources/js/components/sortable-list.js node_1 | add:resources/js/components/submit-on-change.js node_1 | add:resources/js/components/tabs.js node_1 | add:resources/js/components/tag-manager.js node_1 | add:resources/js/components/template-manager.js node_1 | add:resources/js/components/toggle-switch.js node_1 | add:resources/js/components/tri-layout.js node_1 | add:resources/js/components/user-select.js node_1 | add:resources/js/components/webhook-events.js node_1 | add:resources/js/components/wysiwyg-editor.js node_1 | add:resources/js/services/animations.js node_1 | add:resources/js/services/clipboard.js node_1 | add:resources/js/services/dates.js node_1 | add:resources/js/services/dom.js node_1 | add:resources/js/services/drawio.js node_1 | add:resources/js/services/events.js node_1 | add:resources/js/services/http.js node_1 | add:resources/js/services/translations.js node_1 | add:resources/js/services/util.js node_1 | add:resources/js/wysiwyg/common-events.js node_1 | add:resources/js/wysiwyg/config.js node_1 | add:resources/js/wysiwyg/drop-paste-handling.js node_1 | add:resources/js/wysiwyg/plugin-codeeditor.js node_1 | add:resources/js/wysiwyg/plugin-drawio.js node_1 | add:resources/js/wysiwyg/plugins-about.js node_1 | add:resources/js/wysiwyg/plugins-customhr.js node_1 | add:resources/js/wysiwyg/plugins-details.js node_1 | add:resources/js/wysiwyg/plugins-imagemanager.js node_1 | add:resources/js/wysiwyg/plugins-stub.js node_1 | add:resources/js/wysiwyg/plugins-tasklist.js node_1 | add:resources/js/wysiwyg/scrolling.js node_1 | add:resources/js/wysiwyg/shortcuts.js node_1 | add:resources/js/wysiwyg/toolbars.js node_1 | Watching "./resources/**/*.js" .. node_1 | Sass is watching for changes. Press Ctrl-C to stop. node_1 | node_1 | node_1 | > build:js:dev node_1 | > node dev/build/esbuild.js node_1 | node_1 | node_1 | > build:js:dev node_1 | > node dev/build/esbuild.js node_1 | node_1 | node_1 | public/dist/code.js 877.7kb node_1 | public/dist/app.js 825.2kb node_1 | public/dist/code.js.map 1.4mb node_1 | public/dist/app.js.map 1.4mb node_1 | node_1 | ⚡ Done in 1172ms node_1 | node_1 | public/dist/code.js 877.7kb node_1 | public/dist/app.js 825.2kb node_1 | public/dist/code.js.map 1.4mb node_1 | public/dist/app.js.map 1.4mb node_1 | node_1 | ⚡ Done in 999ms app_1 | > Illuminate\Foundation\ComposerScripts::postAutoloadDump app_1 | > @php artisan package:discover --ansi app_1 | Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( app_1 | Discovered Package: barryvdh/laravel-dompdf app_1 | Discovered Package: barryvdh/laravel-snappy app_1 | Discovered Package: intervention/image app_1 | Discovered Package: itsgoingd/clockwork app_1 | Discovered Package: laravel/socialite app_1 | Discovered Package: laravel/tinker app_1 | Discovered Package: laravel/ui app_1 | Discovered Package: nesbot/carbon app_1 | Discovered Package: nunomaduro/collision app_1 | Discovered Package: socialiteproviders/manager app_1 | Package manifest generated successfully. app_1 | Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( app_1 | 100 packages you are using are looking for funding. app_1 | Use the `composer fund` command to find out more! app_1 | > @php artisan cache:clear app_1 | Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( app_1 | Application cache cleared! app_1 | Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( app_1 | > @php artisan view:clear app_1 | Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( app_1 | Compiled views cleared! app_1 | Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( app_1 | wait-for-it: waiting 45 seconds for db:3306 app_1 | wait-for-it: db:3306 is available after 0 seconds app_1 | Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( app_1 | Nothing to migrate. app_1 | Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( app_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.0.3. Set the 'ServerName' directive globally to suppress this message app_1 | AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 192.168.0.3. Set the 'ServerName' directive globally to suppress this message app_1 | [Fri Jun 10 05:55:35.394720 2022] [mpm_prefork:notice] [pid 1] AH00163: Apache/2.4.53 (Debian) PHP/8.1.6 configured -- resuming normal operations app_1 | [Fri Jun 10 05:55:35.394794 2022] [core:notice] [pid 1] AH00094: Command line: 'apache2 -D FOREGROUND' mailhog_1 | [APIv1] KEEPALIVE /api/v1/events app_1 | [Fri Jun 10 05:55:49.497681 2022] [php:notice] [pid 76] [client 192.168.0.1:62726] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( db_1 | mbind: Operation not permitted app_1 | [Fri Jun 10 05:55:50.840577 2022] [php:notice] [pid 76] [client 192.168.0.1:62726] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( app_1 | [Fri Jun 10 05:55:50.843059 2022] [php:notice] [pid 76] [client 192.168.0.1:62726] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-( app_1 | 192.168.0.1 - - [10/Jun/2022:05:55:49 +0000] "GET /knowledge HTTP/1.1" 404 13549 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36" app_1 | [Fri Jun 10 05:55:50.980885 2022] [php:notice] [pid 77] [client 192.168.0.1:62736] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8080/knowledge app_1 | [Fri Jun 10 05:55:50.981285 2022] [php:notice] [pid 76] [client 192.168.0.1:62726] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8080/knowledge app_1 | [Fri Jun 10 05:55:51.020475 2022] [php:notice] [pid 79] [client 192.168.0.1:62744] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8080/knowledge app_1 | [Fri Jun 10 05:55:51.020507 2022] [php:notice] [pid 78] [client 192.168.0.1:62742] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8080/knowledge db_1 | mbind: Operation not permitted db_1 | mbind: Operation not permitted db_1 | mbind: Operation not permitted db_1 | mbind: Operation not permitted app_1 | [Fri Jun 10 05:55:52.914181 2022] [php:notice] [pid 76] [client 192.168.0.1:62726] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8080/knowledge app_1 | [Fri Jun 10 05:55:52.916033 2022] [php:notice] [pid 76] [client 192.168.0.1:62726] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8080/knowledge app_1 | [Fri Jun 10 05:55:52.919936 2022] [php:notice] [pid 78] [client 192.168.0.1:62742] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8080/knowledge app_1 | 192.168.0.1 - - [10/Jun/2022:05:55:50 +0000] "GET /knowledge/dist/styles.css?version=v22.04.2 HTTP/1.1" 404 13564 "http://localhost:8080/knowledge" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36" app_1 | [Fri Jun 10 05:55:52.923847 2022] [php:notice] [pid 78] [client 192.168.0.1:62742] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8080/knowledge app_1 | 192.168.0.1 - - [10/Jun/2022:05:55:50 +0000] "GET /knowledge/dist/app.js?version=v22.04.2 HTTP/1.1" 404 13561 "http://localhost:8080/knowledge" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36" app_1 | [Fri Jun 10 05:55:52.948234 2022] [php:notice] [pid 79] [client 192.168.0.1:62744] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8080/knowledge app_1 | [Fri Jun 10 05:55:52.951449 2022] [php:notice] [pid 79] [client 192.168.0.1:62744] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8080/knowledge app_1 | 192.168.0.1 - - [10/Jun/2022:05:55:50 +0000] "GET /knowledge/dist/print-styles.css?version=v22.04.2 HTTP/1.1" 404 13571 "http://localhost:8080/knowledge" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36" app_1 | [Fri Jun 10 05:55:52.958974 2022] [php:notice] [pid 77] [client 192.168.0.1:62736] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8080/knowledge app_1 | [Fri Jun 10 05:55:52.963930 2022] [php:notice] [pid 77] [client 192.168.0.1:62736] Xdebug: [Step Debug] Could not connect to debugging client. Tried: host.docker.internal:9090 (through xdebug.client_host/xdebug.client_port) :-(, referer: http://localhost:8080/knowledge app_1 | 192.168.0.1 - - [10/Jun/2022:05:55:50 +0000] "GET /uploads/images/system/2022-06/vertical-2colour2.png HTTP/1.1" 404 13584 "http://localhost:8080/knowledge" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.5005.61 Safari/537.36" app_1 | 127.0.0.1 - - [10/Jun/2022:05:55:53 +0000] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) PHP/8.1.6 (internal dummy connection)" app_1 | 127.0.0.1 - - [10/Jun/2022:05:56:00 +0000] "OPTIONS * HTTP/1.0" 200 126 "-" "Apache/2.4.53 (Debian) PHP/8.1.6 (internal dummy connection)" mailhog_1 | [APIv1] KEEPALIVE /api/v1/events ```

PHP Version

PHP 8.1.6

Hosting Environment

Docker on Intel MacBook

ssddanbrown commented 2 years ago

Hi @stevenmasci,

The APP_URL does not dictate/enable the provided url to automatically work. This option is used to tell BookStack what URL has been setup (on the webserver side) to be used.

To get sub-path working you'll need to do some handling on the webserver/proxy side. If you're using a docker setup then proxying the path to the server is common and usually easiest. If attempting to do direct via a single webserver, we have some guidance for this in our docs: https://www.bookstackapp.com/docs/admin/subdirectory-setup/

stevenmasci commented 2 years ago

Thanks again @ssddanbrown

I've managed to get this working with HAProxy by adding reqirep ^([^\ :]*)\ /knowledge/(.*) \1\ /\2 to the HAProxy config.

CIT-Michael commented 2 years ago

Hi @stevenmasci,

The APP_URL does not dictate/enable the provided url to automatically work. This option is used to tell BookStack what URL has been setup (on the webserver side) to be used.

To get sub-path working you'll need to do some handling on the webserver/proxy side. If you're using a docker setup then proxying the path to the server is common and usually easiest. If attempting to do direct via a single webserver, we have some guidance for this in our docs: https://www.bookstackapp.com/docs/admin/subdirectory-setup/

Hi is there any reference of proxying the path, looking forward for your reply

Current setup docker plesk

ssddanbrown commented 2 years ago

@CIT-Michael The "NGINX" section of the linked subdirectory setup docs page contains info on this. It also links to an example nginx config for this kind of setup.