Nginx Serverblock for Bookstack



  • My Bookstack install doesn't like HTTPS. It's fine when I am accessing via HTTP (although I am forcing HTTPS right now.

    Bookstack documentation says nginx server block needs to contain

    location / {
        try_files $uri $uri/ /index.php?$query_string;
    }
    

    Anytime I attempt to add the above it breaks.

    server {
        client_max_body_size 40M;
        server_name wiki.domain.com;
        proxy_set_header X-Real-IP $remote_addr;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header Host $http_host;
        proxy_set_header X-NginX-Proxy true;
        proxy_redirect off;
        location / {
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header Host $http_host;
            proxy_set_header X-NginX-Proxy true;
            proxy_pass http://192.168.1.206;
            proxy_redirect off;
            # Socket.IO Support
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
    
    }
        ssl_stapling on;
        ssl_stapling_verify on;
        ssl_session_cache shared:SSL:10m;
        add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
    
        listen 443 ssl; # managed by Certbot
        ssl_certificate /etc/letsencrypt/live/wiki.domain.com/fullchain.pem; # managed by Certbot
        ssl_certificate_key /etc/letsencrypt/live/wiki.domain.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
    
    }
    server {
        client_max_body_size 40M;
        listen 80;
        server_name wiki.domain.com;
        rewrite        ^ https://$server_name$request_uri? permanent;
    }
    
    

    What am I missing? I installed this via their install script on Ubuntu 16.04.



  • nano /var/www/bookstack/.env contains a commented line for APP_URL=http://bookstack.dev. Uncommenting it and changing it to APP_URL=https://wiki.domain.com fixed the issue for me.