nginx 不显示任何子目录

nginx not showing any subdirectories

我的一个站点有一个 nginx 配置。它显示 /var/www/html/tommiejones 子文件夹中的文件,但不显示子目录。我在顶级目录中有多个文件,并且显示这些文件都很好。

server {
    listen 80;
    listen [::]:80;
    # Add index.php to the list if you are using PHP
    index index.html index.htm;

    server_name www.tommiejones.com tommiejones.com;

    root /var/www/html/tommiejones;

    location ~/api/(.*)$ {
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
            proxy_pass http://127.0.0.1:8000/api/;
    }

    location / {
            root /var/www/html/tommiejones;
            try_files $uri $uri/ =404;
    }

}

index 指令可以替换为 autoindex on

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

    server_name www.tommiejones.com tommiejones.com;
    root /var/www/html/tommiejones;
    try_files $uri $uri/ =404;

    location ~/api/(.*)$ {
            proxy_set_header X-Real-IP  $remote_addr;
            proxy_set_header X-Forwarded-For $remote_addr;
            proxy_set_header Host $host;
            proxy_pass http://127.0.0.1:8000/api/;
    }
}