Serving Drupal from within a sub-directory of my web root I need my Drupal 8 website to be served from within a subdirectory of my NGINX_SERVER_ROOT but is doesn't work.

Drupal should be reached at mydomain.com/drupal. 

My NGINX_SERVER_ROOT is /var/www/html/web.

When the source code is in /var/www/html/web it works fine. But when moved to /var/www/html/web/drupal and I try to reach mydomain.com/drupal, it doesn't work.

I have edited the .htaccess file within the drupal subfolder and set RewriteBase /drupal as explained in the file itself.

Here is the log when I try to access my Drupal installation.

nginx_1    | 2018/10/09 12:58:38 [error] 42#42: *5 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 192.168.160.4, server: default, request: "GET /drupal HTTP/1.1", upstream: "fastcgi://192.168.160.5:9000", host: "d8site.local:8000"
nginx_1    | 192.168.160.4 - - [09/Oct/2018:12:58:38 +0000] "GET /drupal HTTP/1.1" 404 47 "-" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"
nginx_1    | 192.168.160.4 - - [09/Oct/2018:12:58:38 +0000] "GET /favicon.ico HTTP/1.1" 200 43 "http://d8site.local:8000/drupal" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/69.0.3497.100 Safari/537.36"


Could someone point me in the right direction?
You have to edit the nginx virtual host file of your website.
You'll usually find it at /etc/nginx/sites-available/yoursitename.vhost.

Open it with write permissions, and edit root directive at the top of server block as following:

server {
    listen x.x.x.x:yyyy; #IP:port
    server_name www.example.com;
    root /var/www/html/web/drupal;


Save the file and reload nginx conf : sudo systemctl reload nginx.service