BookStackApp / BookStack

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

Apache2 .conf file for reverse Proxy to subdomain. #5328

Closed BerndGit closed 4 days ago

BerndGit commented 4 days ago

Attempted Debugging

Searched GitHub Issues

Describe the Scenario

I want to run bookstack in a docker container. The container exposes port 48080. My Apache2 should act as a reverse proxy from the subdomain bs.mydomain.net -> localhost:48080.

Basicall I can see the login-page, but without style information. Obviously bookstack is not locating some resources correctly.

my docker-compose.yml looks like:

version: '2'
services:
  mysql:
    image: mysql:8.3
    environment:
    - MYSQL_ROOT_PASSWORD=secret
    - MYSQL_DATABASE=bookstack
    - MYSQL_USER=bookstack
    - MYSQL_PASSWORD=password
    volumes:
    - mysql-data:/var/lib/mysql

  bookstack:
    image: solidnerd/bookstack:24.10.2
    depends_on:
    - mysql
    environment:
    - DB_HOST=mysql:3306
    - DB_DATABASE=bookstack
    - DB_USERNAME=bookstack
    - DB_PASSWORD=password
    #set the APP_ to the URL of bookstack without without a trailing slash APP_URL=https://example.com
    - APP_URL=http://bs.mydomain.net
    # APP_KEY is used for encryption where needed, so needs to be persisted to
    # preserve decryption abilities.
    # Can run `php artisan key:generate` to generate a key
    - APP_KEY=abcdefg
    volumes:
    - uploads:/var/www/bookstack/public/uploads
    - storage-uploads:/var/www/bookstack/storage/uploads
    ports:
    - "48080:8080"

volumes:
 mysql-data:
 uploads:
 storage-uploads:

My current .conf file lools like this

<VirtualHost *:80>                                                                  
        ServerName bs.mydomain.net                                                   

        ServerAdmin webmaster@mydomain.net                                           

        ErrorLog ${APACHE_LOG_DIR}/error.log                                        
        CustomLog ${APACHE_LOG_DIR}/access.log combined                             

        RewriteEngine on                                                            
        RewriteCond %{SERVER_NAME} =bs.mydomain.net                                  
        RewriteRule ^ https://%{SERVER_NAME}%{REQUEST_URI} [END,NE,R=permanent]     
</VirtualHost>                                                                      

<VirtualHost *:443>
ServerName bs.mydomain.net

 ErrorLog ${APACHE_LOG_DIR}/error.log                                      
 CustomLog ${APACHE_LOG_DIR}/access.log combined                           

 ProxyRequests Off                                                         
 ProxyPreserveHost On                                                      

 ProxyPass "/" "http://localhost:48080/"                                   
 ProxyPassReverse "/" "http://localhost:48080/"                            
 SSLProxyEngine On                                                         
 SSLEngine On                                                              

  SSLCertificateFile /etc/letsencrypt/live/bs.mydomain.net/fullchain.pem    
  SSLCertificateKeyFile /etc/letsencrypt/live/bs.mydomain.net/privkey.pem   
  Include /etc/letsencrypt/options-ssl-apache.conf                         



### Exact BookStack Version

latest

### Log Content

_No response_

### Hosting Environment

Server version: Apache/2.4.52 (Ubuntu)
ssddanbrown commented 4 days ago

Hi @BerndGit, Try updating the APP_URL option to start with https:// instead of http://, since it looks like you're accessing over https.

BerndGit commented 4 days ago

Hello Dan @ssddanbrown,

It's working now. Great!

Thanks for your fast answer, BerndGit

BerndGit commented 4 days ago

CLOSED