I
I
ironheaddd2019-11-25 13:19:51
Nginx
ironheaddd, 2019-11-25 13:19:51

Why is nginx returning 403?

There is an nginx config:

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

server {
  listen		443 ssl;

  server_name		sub.domain.com;

  root			/home/back/project/randomname/public/;
  index			index.php;

  ssl_certificate 	/etc/letsencrypt/live/randomname/fullchain.pem;
  ssl_certificate_key 	/etc/letsencrypt/live/randomname/privkey.pem;

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

  location /app/ {
    root		/home/back/project/randomname/app;
    index 		index.html;
  }

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

  location ~ \.php$ {
    include		snippets/fastcgi-php.conf;
    fastcgi_pass	unix:/run/php/php7.3-fpm.sock;
  }

  location ~ /\.ht {
    deny all;
  }    
}

The site itself opens, everything works, but when accessing sub.domain.com/app, it returns 403 forbidden.
The rights to the www-data:www-data directory, 777 (tried 755 and 644). The location /app block also resulted in:
location /app {
    root		/home/back/project/randomname/app/;
    index 		index.html;
  }

What could be wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
E
Eugene, 2019-11-25
@Nc_Soft

Don't make multiple root use alias
https://nginx.org/en/docs/http/ngx_http_core_modul...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question