]> BookStack Code Mirror - devops/blob - config/nginx/subpath-proxy-config
Update config/nginx/subpath-proxy-config
[devops] / config / nginx / subpath-proxy-config
1 # This example nginx config file shows a method of hosting BookStack on a 
2 # URL sub path (http://example.com/bookstack). There are many ways to achieve
3 # this but the below method uses a reverse proxy style method to keep the BookStack
4 # configuration contained within it's own server block.
5
6 # There are two server blocks in this file.
7 # The first is pointed at BookStack so has the PHP config, but
8 # this is only intended to be used locally (hence on port 8080 and using "localhost").
9 # The "root" directory is pointed to the "public" folder within your BookStack 
10 # install folder.
11
12 # The second would represent your existing website (http://example.com in this case).
13 # The "location /bookstack/" block will take web requests to `/bookstack/` and proxy 
14 # them to the first internal-only server block. 
15
16 # Note: The "root" of the first server block should not be a child directory of the 
17 #       second server block. This would likely cause an insecure setup.
18
19 server {
20   listen 8080;
21   listen [::]:8080;
22
23   server_name localhost;
24
25   root /var/www/bookstack/public;
26   index index.php index.html;
27
28   location / {
29     try_files $uri $uri/ /index.php?$query_string;
30   }
31   
32   location ~ \.php$ {
33     include snippets/fastcgi-php.conf;
34     # If your PHP version is not 8.3, then update the socket to point at the correct version.
35     fastcgi_pass unix:/run/php/php8.3-fpm.sock;
36   }
37 }
38
39
40 server {
41   listen 80;
42   listen [::]:80;
43
44   server_name example.com;
45
46   root /var/www/html;
47   index index.html;
48
49   location /bookstack/ {
50     proxy_pass http://localhost:8080/;
51     proxy_redirect off;
52   }
53   
54 }