[Support Request]: How to install Lets Encrypt via Nginx? #2578

Closed
opened 2026-02-05 04:33:16 +03:00 by OVERLORD · 5 comments
Owner

Originally created by @aes4096 on GitHub (Jan 17, 2022).

Attempted Debugging

  • I have read the debugging page

Searched GitHub Issues

  • I have searched GitHub for the issue.

Describe the Scenario

Hello! How to install Lets Encrypt via Nginx? My Nginx config:

I have modified the standard installation script for Ubuntu 20.04:

I am getting an error 502 Bad Gateway. What am I doing wrong?

Exact BookStack Version

last

Log Content

No response

PHP Version

8.0

Hosting Environment

Ubuntu 20.04

Originally created by @aes4096 on GitHub (Jan 17, 2022). ### Attempted Debugging - [X] I have read the debugging page ### Searched GitHub Issues - [X] I have searched GitHub for the issue. ### Describe the Scenario Hello! How to install Lets Encrypt via Nginx? My Nginx config: I have modified the standard installation script for Ubuntu 20.04: I am getting an error 502 Bad Gateway. What am I doing wrong? ### Exact BookStack Version last ### Log Content _No response_ ### PHP Version 8.0 ### Hosting Environment Ubuntu 20.04
OVERLORD added the 🐕 Support label 2026-02-05 04:33:16 +03:00
Author
Owner

@ssddanbrown commented on GitHub (Jan 17, 2022):

Hi @aes4096,

This could be due to a number of things. The best method to find the issue would be to check your nginx error log (Often found at /var/log/nginx/error.log).

From a glance over your config, and due to the error observed, my suspicion would be the PHP passing location.
From my experience Ubuntu setups don't often have a /var/run/php-fpm path, with instead of FPM sockets being located in /var/run/php.

I typically use something like this for the PHP handling on Ubuntu: 0c0a2ccc4d/config/nginx (L14-L17)

@ssddanbrown commented on GitHub (Jan 17, 2022): Hi @aes4096, This could be due to a number of things. The best method to find the issue would be to check your nginx error log (Often found at `/var/log/nginx/error.log`). From a glance over your config, and due to the error observed, my suspicion would be the PHP passing location. From my experience Ubuntu setups don't often have a `/var/run/php-fpm` path, with instead of FPM sockets being located in `/var/run/php`. I typically use something like this for the PHP handling on Ubuntu: https://github.com/BookStackApp/devops/blob/0c0a2ccc4d74b7aed0301b08a391991eca7fa658/config/nginx#L14-L17
Author
Owner

@aes4096 commented on GitHub (Jan 17, 2022):

Hi @aes4096,

This could be due to a number of things. The best method to find the issue would be to check your nginx error log (Often found at /var/log/nginx/error.log).

From a glance over your config, and due to the error observed, my suspicion would be the PHP passing location. From my experience Ubuntu setups don't often have a /var/run/php-fpm path, with instead of FPM sockets being located in /var/run/php.

I typically use something like this for the PHP handling on Ubuntu: 0c0a2ccc4d/config/nginx (L14-L17)

I replace php-sock, but it not work. My full Nginx config (BookStack + NextCloud)
BookStack not worked on HTTP. If I follow the link of bookstack.domain.ru, that redirects to other link (nextcloud.domain.ru).

I entered domain bookstack.domain.ru at the beginning of the installation.

@aes4096 commented on GitHub (Jan 17, 2022): > Hi @aes4096, > > This could be due to a number of things. The best method to find the issue would be to check your nginx error log (Often found at `/var/log/nginx/error.log`). > > From a glance over your config, and due to the error observed, my suspicion would be the PHP passing location. From my experience Ubuntu setups don't often have a `/var/run/php-fpm` path, with instead of FPM sockets being located in `/var/run/php`. > > I typically use something like this for the PHP handling on Ubuntu: https://github.com/BookStackApp/devops/blob/0c0a2ccc4d74b7aed0301b08a391991eca7fa658/config/nginx#L14-L17 I replace php-sock, but it not work. My full Nginx config (BookStack + NextCloud) BookStack not worked on HTTP. If I follow the link of bookstack.domain.ru, that redirects to other link (nextcloud.domain.ru). I entered domain bookstack.domain.ru at the beginning of the installation.
Author
Owner

@ssddanbrown commented on GitHub (Jan 17, 2022):

I replace php-sock, but it not work. My full Nginx config (BookStack + NextCloud): nginx.conf.txt

Based upon that, you currently have no server block for server_name bookstack.aes4096.ru where you're listening on port 443. You only have a port 80 block for bookstack, which appears to be working when I visit that domain.

@ssddanbrown commented on GitHub (Jan 17, 2022): > I replace php-sock, but it not work. My full Nginx config (BookStack + NextCloud): nginx.conf.txt Based upon that, you currently have no server block for `server_name bookstack.aes4096.ru` where you're listening on port 443. You only have a port 80 block for bookstack, which appears to be working when I visit that domain.
Author
Owner

@aes4096 commented on GitHub (Jan 17, 2022):

I replace php-sock, but it not work. My full Nginx config (BookStack + NextCloud): nginx.conf.txt

Based upon that, you currently have no server block for server_name bookstack.aes4096.ru where you're listening on port 443. You only have a port 80 block for bookstack, which appears to be working when I visit that domain.

Yes you are right. Port 80 is working. Cleared browser cache. I managed to do it on port 443. It works. I'm attaching the config if anyone needs it.

server {
listen 80;
server_name bookstack.domain.ru;
return 301 https://$server_name$request_uri;
}

server {
listen 443;
listen [::]:443;
root /var/www/bookstack.domain.ru/bookstack/public;
index index.php index.html index.htm;
server_name bookstack.domain.ru;

client_max_body_size 100M;

 ssl_certificate    /etc/letsencrypt/live/bookstack.domain.ru/cert.pem;
 ssl_certificate_key    /etc/letsencrypt/live/bookstack.domain.ru/privkey.pem;
 ssl_stapling on;
 ssl_stapling_verify on;
 ssl_protocols TLSv1.1 TLSv1.2;
 add_header Strict-Transport-Security "max-age=31536000";

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

location ~ \.php$ {
    include snippets/fastcgi-php.conf;
    fastcgi_pass php-handler;
    fastcgi_param   SCRIPT_FILENAME $document_root$fastcgi_script_name;
 }

}

@aes4096 commented on GitHub (Jan 17, 2022): > > I replace php-sock, but it not work. My full Nginx config (BookStack + NextCloud): nginx.conf.txt > > Based upon that, you currently have no server block for `server_name bookstack.aes4096.ru` where you're listening on port 443. You only have a port 80 block for bookstack, which appears to be working when I visit that domain. Yes you are right. Port 80 is working. Cleared browser cache. I managed to do it on port 443. It works. I'm attaching the config if anyone needs it. server { listen 80; server_name bookstack.domain.ru; return 301 https://$server_name$request_uri; } server { listen 443; listen [::]:443; root /var/www/bookstack.domain.ru/bookstack/public; index index.php index.html index.htm; server_name bookstack.domain.ru; client_max_body_size 100M; ssl_certificate /etc/letsencrypt/live/bookstack.domain.ru/cert.pem; ssl_certificate_key /etc/letsencrypt/live/bookstack.domain.ru/privkey.pem; ssl_stapling on; ssl_stapling_verify on; ssl_protocols TLSv1.1 TLSv1.2; add_header Strict-Transport-Security "max-age=31536000"; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { include snippets/fastcgi-php.conf; fastcgi_pass php-handler; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; } }
Author
Owner

@ssddanbrown commented on GitHub (Jan 20, 2022):

Good to hear you got things working. Will therefore close this off.

@ssddanbrown commented on GitHub (Jan 20, 2022): Good to hear you got things working. Will therefore close this off.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#2578