Nginx Reverse Proxy with Letsencrypt, displays Website wrong #2056

Closed
opened 2026-02-05 02:45:17 +03:00 by OVERLORD · 2 comments
Owner

Originally created by @harrytuttle1 on GitHub (Jan 24, 2021).

Describe the bug
Hello,

I just discovered BookStack, and wanted to try it out on a Ubuntu VM. I installed BookStack using the installation script, changed the Apache port to 9999, so I can use Nginx as reverse proxy, with Letsencrypt. After doing all that, the site is being displayed completly wrong, as tough, CSS etc. aren't applied. Im not much of a programmer, so I hope someone can help me out. My configs for both Apache and Nginx are below, as well is my system info.

Steps To Reproduce
Steps to reproduce the behavior:

  1. Install BookStack using this script: https://github.com/BookStackApp/devops/blob/master/scripts/installation-ubuntu-18.04.sh
  2. Installl NGINX as Reverse Proxy and create Letsencrypt Certificate

Expected behavior
Normal BookStack Login Screen

Screenshots
screen-bookstack

Your Configuration (please complete the following information):

  • Exact BookStack Version (Found in settings): v0.31.4
  • PHP Version: PHP 7.2.24-0ubuntu0.18.04.7 (cli)
  • Hosting Method (Nginx/Apache/Docker): Apache/2.4.29 (Ubuntu), nginx/1.14.0 (Ubuntu)
  • OS: 18.04.5 LTS (Bionic Beaver)

Additional context
Apache2 Config: (/etc/apache2/ports.conf only contains Listen 9999)

<VirtualHost *:9999>
        ServerName bookstack.example.com
        DocumentRoot /var/www/bookstack/public/

<Directory /var/www/bookstack/public/>
        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
        <IfModule mod_rewrite.c>
            <IfModule mod_negotiation.c>
                Options -MultiViews -Indexes
            </IfModule>
            RewriteEngine On
            # Handle Authorization Header
            RewriteCond %{HTTP:Authorization} .
            RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
            # Redirect Trailing Slashes If Not A Folder...
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_URI} (.+)/$
            RewriteRule ^ %1 [L,R=301]
            # Handle Front Controller...
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteRule ^ index.php [L]
        </IfModule>
    </Directory>
        #ErrorLog \${APACHE_LOG_DIR}/error.log
        #CustomLog \${APACHE_LOG_DIR}/access.log combined

</VirtualHost>
upstream backend {
  server 127.0.0.1:9999;
}

server {
    server_name bookstack.example.com;
    listen [::]:443 ssl ipv6only=on; # managed by Certbot
    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/bookstack.example.com/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/bookstack.example.com/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
    location / {
        proxy_pass http://backend;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $http_host;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto https;
        proxy_set_header X-Nginx-Proxy true;
        proxy_redirect off;

    }


}

server {
    if ($host = bookstack.example.com) {
        return 301 https://$host$request_uri;
    } # managed by Certbot


    listen 80;
    listen [::]:80;
    server_name bookstack.example.com;
    return 404; # managed by Certbot


}
Originally created by @harrytuttle1 on GitHub (Jan 24, 2021). **Describe the bug** Hello, I just discovered BookStack, and wanted to try it out on a Ubuntu VM. I installed BookStack using the installation script, changed the Apache port to 9999, so I can use Nginx as reverse proxy, with Letsencrypt. After doing all that, the site is being displayed completly wrong, as tough, CSS etc. aren't applied. Im not much of a programmer, so I hope someone can help me out. My configs for both Apache and Nginx are below, as well is my system info. **Steps To Reproduce** Steps to reproduce the behavior: 1. Install BookStack using this script: https://github.com/BookStackApp/devops/blob/master/scripts/installation-ubuntu-18.04.sh 2. Installl NGINX as Reverse Proxy and create Letsencrypt Certificate **Expected behavior** Normal BookStack Login Screen **Screenshots** ![screen-bookstack](https://user-images.githubusercontent.com/77901507/105614867-8fab1e80-5dcc-11eb-979c-cb20302986bd.jpg) **Your Configuration (please complete the following information):** - Exact BookStack Version (Found in settings): v0.31.4 - PHP Version: PHP 7.2.24-0ubuntu0.18.04.7 (cli) - Hosting Method (Nginx/Apache/Docker): Apache/2.4.29 (Ubuntu), nginx/1.14.0 (Ubuntu) - OS: 18.04.5 LTS (Bionic Beaver) **Additional context** Apache2 Config: (/etc/apache2/ports.conf only contains Listen 9999) ``` <VirtualHost *:9999> ServerName bookstack.example.com DocumentRoot /var/www/bookstack/public/ <Directory /var/www/bookstack/public/> Options Indexes FollowSymLinks AllowOverride None Require all granted <IfModule mod_rewrite.c> <IfModule mod_negotiation.c> Options -MultiViews -Indexes </IfModule> RewriteEngine On # Handle Authorization Header RewriteCond %{HTTP:Authorization} . RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}] # Redirect Trailing Slashes If Not A Folder... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_URI} (.+)/$ RewriteRule ^ %1 [L,R=301] # Handle Front Controller... RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-f RewriteRule ^ index.php [L] </IfModule> </Directory> #ErrorLog \${APACHE_LOG_DIR}/error.log #CustomLog \${APACHE_LOG_DIR}/access.log combined </VirtualHost> ``` ``` upstream backend { server 127.0.0.1:9999; } server { server_name bookstack.example.com; listen [::]:443 ssl ipv6only=on; # managed by Certbot listen 443 ssl; # managed by Certbot ssl_certificate /etc/letsencrypt/live/bookstack.example.com/fullchain.pem; # managed by Certbot ssl_certificate_key /etc/letsencrypt/live/bookstack.example.com/privkey.pem; # managed by Certbot include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot location / { proxy_pass http://backend; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "upgrade"; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Nginx-Proxy true; proxy_redirect off; } } server { if ($host = bookstack.example.com) { return 301 https://$host$request_uri; } # managed by Certbot listen 80; listen [::]:80; server_name bookstack.example.com; return 404; # managed by Certbot } ```
Author
Owner

@ssddanbrown commented on GitHub (Jan 24, 2021):

Hi @harrytuttle1,
Can you check your /var/www/bookstack/.env file and ensure your APP_URL option starts with https:// and matches the base URL you're accessing BookStack on?

@ssddanbrown commented on GitHub (Jan 24, 2021): Hi @harrytuttle1, Can you check your `/var/www/bookstack/.env` file and ensure your `APP_URL` option starts with `https://` and matches the base URL you're accessing BookStack on?
Author
Owner

@harrytuttle1 commented on GitHub (Jan 24, 2021):

Thanks @ssddanbrown, that fixed it.

@harrytuttle1 commented on GitHub (Jan 24, 2021): Thanks @ssddanbrown, that fixed it.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2056