403 Forbidden #1845

Closed
opened 2026-02-05 02:01:51 +03:00 by OVERLORD · 7 comments
Owner

Originally created by @JayRhithu on GitHub (Sep 7, 2020).

Debian 10, nginx/1.14.2, PHP 7.3
reference: https://www.vultr.com/docs/how-to-install-bookstack-on-debian-9

I am trying to install BookStack in local host. After successfull installation its showing:
http://localhost/bookstack/public/

403 Forbidden

and in log:

directory index of "/var/www/html/bookstack/public/" is forbidden, client: ::1, server: _,

  • Given directory permission to www-data:www-data.

  • Changed 'try_files $uri $uri/ /index.php?$query_string;' to 'try_files $uri /index.php?$query_string;'

Yet the result is same. How to resolve this issue? Pls help.

Originally created by @JayRhithu on GitHub (Sep 7, 2020). Debian 10, nginx/1.14.2, PHP 7.3 reference: https://www.vultr.com/docs/how-to-install-bookstack-on-debian-9 I am trying to install BookStack in local host. After successfull installation its showing: http://localhost/bookstack/public/ 403 Forbidden and in log: `directory index of "/var/www/html/bookstack/public/" is forbidden, client: ::1, server: _,` * Given directory permission to `www-data:www-data`. * Changed '`try_files $uri $uri/ /index.php?$query_string;`' to '`try_files $uri /index.php?$query_string;`' Yet the result is same. How to resolve this issue? Pls help.
Author
Owner

@ryanc-me commented on GitHub (Sep 8, 2020):

The directory index of [...] is forbidden error relates to directory-indexing, e.g. showing a list of files contained in a directory (something like this). You probably do not want directory-indexing enabled.

This is most likely a configuration problem.

Could you please show:

  • ls -la /var/www/html/bookstack
  • Your nginx config file

And we may be able to help 🙂

@ryanc-me commented on GitHub (Sep 8, 2020): The `directory index of [...] is forbidden` error relates to directory-indexing, e.g. showing a list of files contained in a directory (something like [this](https://www.keycdn.com/img/support/nginx-directory-index-listing-lg.webp)). You probably do not want directory-indexing enabled. This is most likely a configuration problem. Could you please show: - `ls -la /var/www/html/bookstack` - Your nginx config file And we may be able to help 🙂
Author
Owner

@JayRhithu commented on GitHub (Sep 8, 2020):

Hi, thank you for your kind response. Here are the details:

$ ls -la /var/www/html/bookstack/
total 640
drwxr-xr-x 15 www-data www-data   4096 Sep  7 13:25 .
drwxr-xr-x  3 root     root       4096 Sep  7 13:15 ..
drwxr-xr-x 16 www-data www-data   4096 Sep  7 13:17 app
-rwxr-xr-x  1 www-data www-data   1528 Sep  7 13:17 artisan
drwxr-xr-x  3 www-data www-data   4096 Sep  7 13:17 bootstrap
-rw-r--r--  1 www-data www-data   3471 Sep  7 13:17 composer.json
-rw-r--r--  1 www-data www-data 278567 Sep  7 13:17 composer.lock
-rw-r--r--  1 www-data www-data    200 Sep  7 13:17 crowdin.yml
drwxr-xr-x  5 www-data www-data   4096 Sep  7 13:17 database
drwxr-xr-x  4 www-data www-data   4096 Sep  7 13:17 dev
-rw-r--r--  1 www-data www-data   1091 Sep  7 13:17 docker-compose.yml
-rw-r--r--  1 www-data www-data    905 Sep  7 13:27 .env
-rw-r--r--  1 www-data www-data    870 Sep  7 13:24 .env.example
-rw-r--r--  1 www-data www-data   7986 Sep  7 13:25 .env.example.complete
drwxr-xr-x  8 www-data www-data   4096 Sep  7 13:17 .git
-rw-r--r--  1 www-data www-data     61 Sep  7 13:17 .gitattributes
drwxr-xr-x  4 www-data www-data   4096 Sep  7 13:17 .github
-rw-r--r--  1 www-data www-data    351 Sep  7 13:17 .gitignore
-rw-r--r--  1 www-data www-data   1177 Sep  7 13:17 LICENSE
-rw-r--r--  1 www-data www-data   1097 Sep  7 13:17 package.json
-rw-r--r--  1 www-data www-data 222385 Sep  7 13:17 package-lock.json
-rw-r--r--  1 www-data www-data    251 Sep  7 13:17 phpcs.xml
-rw-r--r--  1 www-data www-data   2451 Sep  7 13:17 phpunit.xml
drwxr-xr-x  5 www-data www-data   4096 Sep  7 13:17 public
-rw-r--r--  1 www-data www-data  13430 Sep  7 13:17 readme.md
drwxr-xr-x  7 www-data www-data   4096 Sep  7 13:17 resources
drwxr-xr-x  2 www-data www-data   4096 Sep  7 13:17 routes
-rw-r--r--  1 www-data www-data    567 Sep  7 13:17 server.php
drwxr-xr-x  7 www-data www-data   4096 Sep  7 13:17 storage
drwxr-xr-x 10 www-data www-data   4096 Sep  7 13:17 tests
drwxr-xr-x  2 www-data www-data   4096 Sep  7 13:17 themes
drwxr-xr-x 59 www-data www-data   4096 Sep  7 13:22 vendor
-rw-r--r--  1 www-data www-data      8 Sep  7 13:17 version
-rw-r--r--  1 www-data www-data   1365 Sep  7 13:17 webpack.config.js

nginx.conf

user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
	worker_connections 768;
	# multi_accept on;
}

http {

	##
	# Basic Settings
	##

	sendfile on;
	tcp_nopush on;
	tcp_nodelay on;
	keepalive_timeout 65;
	types_hash_max_size 2048;
	# server_tokens off;

	# server_names_hash_bucket_size 64;
	# server_name_in_redirect off;

	include /etc/nginx/mime.types;
	default_type application/octet-stream;

	##
	# SSL Settings
	##

	ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
	ssl_prefer_server_ciphers on;

	##
	# Logging Settings
	##

	access_log /var/log/nginx/access.log;
	error_log /var/log/nginx/error.log;

	##
	# Gzip Settings
	##

	gzip on;

	# gzip_vary on;
	# gzip_proxied any;
	# gzip_comp_level 6;
	# gzip_buffers 16 8k;
	# gzip_http_version 1.1;
	# gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;

	##
	# Virtual Host Configs
	##

	include /etc/nginx/conf.d/*.conf;
	include /etc/nginx/sites-enabled/*;
}


#mail {
#	# See sample authentication script at:
#	# http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript
# 
#	# auth_http localhost/auth.php;
#	# pop3_capabilities "TOP" "USER";
#	# imap_capabilities "IMAP4rev1" "UIDPLUS";
# 
#	server {
#		listen     localhost:110;
#		protocol   pop3;
#		proxy      on;
#	}
# 
#	server {
#		listen     localhost:143;
#		protocol   imap;
#		proxy      on;
#	}
#}


sites-enabled/bookstack.conf

server {
  listen 80;
  listen [::]:80;

  server_name bookstack;

  root /var/www/html/bookstack/public;
  index index.php;

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

  location ~ \.php$ {
    fastcgi_index index.php;
    try_files $uri =404;
    include fastcgi_params;
    fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
    fastcgi_pass unix:/run/php/php7.3-fpm.sock;
  }
}

@JayRhithu commented on GitHub (Sep 8, 2020): Hi, thank you for your kind response. Here are the details: ``` $ ls -la /var/www/html/bookstack/ total 640 drwxr-xr-x 15 www-data www-data 4096 Sep 7 13:25 . drwxr-xr-x 3 root root 4096 Sep 7 13:15 .. drwxr-xr-x 16 www-data www-data 4096 Sep 7 13:17 app -rwxr-xr-x 1 www-data www-data 1528 Sep 7 13:17 artisan drwxr-xr-x 3 www-data www-data 4096 Sep 7 13:17 bootstrap -rw-r--r-- 1 www-data www-data 3471 Sep 7 13:17 composer.json -rw-r--r-- 1 www-data www-data 278567 Sep 7 13:17 composer.lock -rw-r--r-- 1 www-data www-data 200 Sep 7 13:17 crowdin.yml drwxr-xr-x 5 www-data www-data 4096 Sep 7 13:17 database drwxr-xr-x 4 www-data www-data 4096 Sep 7 13:17 dev -rw-r--r-- 1 www-data www-data 1091 Sep 7 13:17 docker-compose.yml -rw-r--r-- 1 www-data www-data 905 Sep 7 13:27 .env -rw-r--r-- 1 www-data www-data 870 Sep 7 13:24 .env.example -rw-r--r-- 1 www-data www-data 7986 Sep 7 13:25 .env.example.complete drwxr-xr-x 8 www-data www-data 4096 Sep 7 13:17 .git -rw-r--r-- 1 www-data www-data 61 Sep 7 13:17 .gitattributes drwxr-xr-x 4 www-data www-data 4096 Sep 7 13:17 .github -rw-r--r-- 1 www-data www-data 351 Sep 7 13:17 .gitignore -rw-r--r-- 1 www-data www-data 1177 Sep 7 13:17 LICENSE -rw-r--r-- 1 www-data www-data 1097 Sep 7 13:17 package.json -rw-r--r-- 1 www-data www-data 222385 Sep 7 13:17 package-lock.json -rw-r--r-- 1 www-data www-data 251 Sep 7 13:17 phpcs.xml -rw-r--r-- 1 www-data www-data 2451 Sep 7 13:17 phpunit.xml drwxr-xr-x 5 www-data www-data 4096 Sep 7 13:17 public -rw-r--r-- 1 www-data www-data 13430 Sep 7 13:17 readme.md drwxr-xr-x 7 www-data www-data 4096 Sep 7 13:17 resources drwxr-xr-x 2 www-data www-data 4096 Sep 7 13:17 routes -rw-r--r-- 1 www-data www-data 567 Sep 7 13:17 server.php drwxr-xr-x 7 www-data www-data 4096 Sep 7 13:17 storage drwxr-xr-x 10 www-data www-data 4096 Sep 7 13:17 tests drwxr-xr-x 2 www-data www-data 4096 Sep 7 13:17 themes drwxr-xr-x 59 www-data www-data 4096 Sep 7 13:22 vendor -rw-r--r-- 1 www-data www-data 8 Sep 7 13:17 version -rw-r--r-- 1 www-data www-data 1365 Sep 7 13:17 webpack.config.js ``` -------------------------------------------------------------------------------- nginx.conf ``` user www-data; worker_processes auto; pid /run/nginx.pid; include /etc/nginx/modules-enabled/*.conf; events { worker_connections 768; # multi_accept on; } http { ## # Basic Settings ## sendfile on; tcp_nopush on; tcp_nodelay on; keepalive_timeout 65; types_hash_max_size 2048; # server_tokens off; # server_names_hash_bucket_size 64; # server_name_in_redirect off; include /etc/nginx/mime.types; default_type application/octet-stream; ## # SSL Settings ## ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE ssl_prefer_server_ciphers on; ## # Logging Settings ## access_log /var/log/nginx/access.log; error_log /var/log/nginx/error.log; ## # Gzip Settings ## gzip on; # gzip_vary on; # gzip_proxied any; # gzip_comp_level 6; # gzip_buffers 16 8k; # gzip_http_version 1.1; # gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; ## # Virtual Host Configs ## include /etc/nginx/conf.d/*.conf; include /etc/nginx/sites-enabled/*; } #mail { # # See sample authentication script at: # # http://wiki.nginx.org/ImapAuthenticateWithApachePhpScript # # # auth_http localhost/auth.php; # # pop3_capabilities "TOP" "USER"; # # imap_capabilities "IMAP4rev1" "UIDPLUS"; # # server { # listen localhost:110; # protocol pop3; # proxy on; # } # # server { # listen localhost:143; # protocol imap; # proxy on; # } #} ``` ---------------------------------------------------------------------------- sites-enabled/bookstack.conf ``` server { listen 80; listen [::]:80; server_name bookstack; root /var/www/html/bookstack/public; index index.php; location / { try_files $uri $uri/ /index.php?$query_string; } location ~ \.php$ { fastcgi_index index.php; try_files $uri =404; include fastcgi_params; fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name; fastcgi_pass unix:/run/php/php7.3-fpm.sock; } } ``` ----------------------------------------------------------------------------
Author
Owner

@ryanc-me commented on GitHub (Sep 8, 2020):

Can you also show ls -la /var/www/html/bookstack/public?

@ryanc-me commented on GitHub (Sep 8, 2020): Can you also show `ls -la /var/www/html/bookstack/public`?
Author
Owner

@JayRhithu commented on GitHub (Sep 8, 2020):

$ ls -la /var/www/html/bookstack/public/
total 80
drwxr-xr-x  5 www-data www-data  4096 Sep  7 13:17 .
drwxr-xr-x 15 www-data www-data  4096 Sep  7 13:25 ..
-rw-r--r--  1 www-data www-data  5672 Sep  7 13:17 book_default_cover.png
drwxr-xr-x  2 www-data www-data  4096 Sep  7 13:17 dist
-rw-r--r--  1 www-data www-data 10933 Sep  7 13:17 favicon.ico
-rw-r--r--  1 www-data www-data   562 Sep  7 13:17 .htaccess
-rw-r--r--  1 www-data www-data  1711 Sep  7 13:17 index.php
drwxr-xr-x  3 www-data www-data  4096 Sep  7 13:17 libs
-rw-r--r--  1 www-data www-data 11098 Sep  7 13:17 loading.gif
-rw-r--r--  1 www-data www-data  5415 Sep  7 13:17 logo.png
drwxr-xr-x  2 www-data www-data  4096 Sep  7 13:17 uploads
-rw-r--r--  1 www-data www-data  7405 Sep  7 13:17 user_avatar.png
-rw-r--r--  1 www-data www-data  1193 Sep  7 13:17 web.config

@JayRhithu commented on GitHub (Sep 8, 2020): ``` $ ls -la /var/www/html/bookstack/public/ total 80 drwxr-xr-x 5 www-data www-data 4096 Sep 7 13:17 . drwxr-xr-x 15 www-data www-data 4096 Sep 7 13:25 .. -rw-r--r-- 1 www-data www-data 5672 Sep 7 13:17 book_default_cover.png drwxr-xr-x 2 www-data www-data 4096 Sep 7 13:17 dist -rw-r--r-- 1 www-data www-data 10933 Sep 7 13:17 favicon.ico -rw-r--r-- 1 www-data www-data 562 Sep 7 13:17 .htaccess -rw-r--r-- 1 www-data www-data 1711 Sep 7 13:17 index.php drwxr-xr-x 3 www-data www-data 4096 Sep 7 13:17 libs -rw-r--r-- 1 www-data www-data 11098 Sep 7 13:17 loading.gif -rw-r--r-- 1 www-data www-data 5415 Sep 7 13:17 logo.png drwxr-xr-x 2 www-data www-data 4096 Sep 7 13:17 uploads -rw-r--r-- 1 www-data www-data 7405 Sep 7 13:17 user_avatar.png -rw-r--r-- 1 www-data www-data 1193 Sep 7 13:17 web.config ``` ---------------------------------------------------------------------------------
Author
Owner

@ryanc-me commented on GitHub (Sep 9, 2020):

Hmm, everything seems to be correct.

It's hard to debug issues like this without access to the system, so I can only provide some suggestions:

  1. Does /run/php/php7.3-fpm.sock exist? The fpm socket may be named something different depending on the PHP version (try ls -la /run/php/ to see which sockets are available). If nothing
  2. Is php-fpm running? (try systemctl list-units --type=service | grep fpm to see the service name, then systemctl status whatever.service).
  3. Are you sure server_name bookstack in the Nginx config is correct? With that set, Bookstack will only be available from http://bookstack/blah. Perhaps server_name 127.0.0.20 or similar would work better (then access via http://127.0.0.20/).
  4. If none of that works, could you post:
    a. The full Nginx logs
    b. php -v
    c. nginx -t
@ryanc-me commented on GitHub (Sep 9, 2020): Hmm, everything seems to be correct. It's hard to debug issues like this without access to the system, so I can only provide some suggestions: 1. Does `/run/php/php7.3-fpm.sock` exist? The fpm socket may be named something different depending on the PHP version (try `ls -la /run/php/` to see which sockets are available). If nothing 2. Is php-fpm running? (try `systemctl list-units --type=service | grep fpm` to see the service name, then `systemctl status whatever.service`). 3. Are you sure `server_name bookstack` in the Nginx config is correct? With that set, Bookstack will only be available from `http://bookstack/blah`. Perhaps `server_name 127.0.0.20` or similar would work better (then access via `http://127.0.0.20/`). 4. If none of that works, could you post: a. The full Nginx logs b. `php -v` c. `nginx -t`
Author
Owner

@JayRhithu commented on GitHub (Sep 9, 2020):

Hurrah....

The third point itself solved the issue... changes made in bookstack.conf file server_name bookstack to server_name 127.0.0.20. And in browser http://127.0.0.20/login. It workes like a charm.

Thank you very much for your kind support and guidance.

@JayRhithu commented on GitHub (Sep 9, 2020): Hurrah.... The third point itself solved the issue... changes made in bookstack.conf file `server_name bookstack` to `server_name 127.0.0.20`. And in browser http://127.0.0.20/login. It workes like a charm. Thank you very much for your kind support and guidance.
Author
Owner

@ryanc-me commented on GitHub (Sep 9, 2020):

Woo, glad to hear you got it sorted! 😁

@ryanc-me commented on GitHub (Sep 9, 2020): Woo, glad to hear you got it sorted! 😁
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/BookStack#1845