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

Closed
opened 2026-02-05 09:37:08 +03:00 by OVERLORD · 3 comments
Owner

Originally created by @BerndGit on GitHub (Nov 17, 2024).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

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                         
</VirtualHost>                                                                 

Exact BookStack Version

latest

Log Content

No response

Hosting Environment

Server version: Apache/2.4.52 (Ubuntu)

Originally created by @BerndGit on GitHub (Nov 17, 2024). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### 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 </VirtualHost> ``` ### Exact BookStack Version latest ### Log Content _No response_ ### Hosting Environment Server version: Apache/2.4.52 (Ubuntu)
OVERLORD added the 🐕 Support label 2026-02-05 09:37:08 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Nov 17, 2024):

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

@ssddanbrown commented on GitHub (Nov 17, 2024): Hi @BerndGit, Try updating the `APP_URL` option to start with `https://` instead of `http://`, since it looks like you're accessing over https.
Author
Owner

@BerndGit commented on GitHub (Nov 17, 2024):

Hello Dan @ssddanbrown,

It's working now. Great!

Thanks for your fast answer,
BerndGit

@BerndGit commented on GitHub (Nov 17, 2024): Hello Dan @ssddanbrown, It's working now. Great! Thanks for your fast answer, BerndGit
Author
Owner

@BerndGit commented on GitHub (Nov 17, 2024):

CLOSED

@BerndGit commented on GitHub (Nov 17, 2024): CLOSED
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#5056