使用Nginx webserver将/tmp/目录作为/npm-logs服务器

zynd9foi  于 2023-10-17  发布在  Nginx
关注(0)|答案(1)|浏览(110)

我希望在Nginx中将/tmp/目录暴露为/npm-logs
我希望通过点击这个URL来提供/tmp目录的内容:https://portal.sggs.com.au/npm-logs
下面是服务器块的样子:

server {
        listen       443 ssl http2 default_server;
        listen       [::]:443 ssl http2 default_server;
        server_name _;
        ssl_certificate "/etc/letsencrypt/live/portal.sggs.com.au/fullchain.pem";
        ssl_certificate_key "/etc/letsencrypt/live/portal.sggs.com.au/privkey.pem";
        ssl_session_cache shared:SSL:1m;
        ssl_session_timeout  10m;
        ssl_ciphers PROFILE=SYSTEM;
        ssl_prefer_server_ciphers on;
        include /etc/nginx/default.d/*.conf;

        location /npm-logs/ {
        autoindex on;
        alias /tmp/;
        add_header Cache-Control "no-store, no-cache, must-revalidate, max-age=0";
        }

        location / {
    alias /var/www/SGGS/SGGS_PROD_UI/build/;
    index  index.html index.htm;
        try_files $uri /index.html;
       }
  }

/var/www/logs/nginx/error.log不记录任何内容。
nginx access.log获取以下条目:

103.97.96.31 - - [06/Sep/2023:19:30:04 +0000] "GET /npm-logs HTTP/2.0" 304 0 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36"

下面是目录权限:

[Wed Sep 06 19:34:46 root@SGGS-Prod:/var/www/SGGS/SGGS_PROD_API ] $ ls -ld /tmp
drwxrwxrwt. 7 root root 4096 Sep  6 19:33 /tmp

下面是nginx的进程:

[Wed Sep 06 19:34:52 root@SGGS-Prod:/var/www/SGGS/SGGS_PROD_API ] $ ps -ef | grep nginx
root      603490       1  0 19:29 ?        00:00:00 nginx: master process /usr/sbin/nginx
nginx     603491  603490  0 19:29 ?        00:00:00 nginx: worker process
nginx     603492  603490  0 19:29 ?        00:00:00 nginx: worker process
root      603534  603173  0 19:32 pts/1    00:00:00 vi /etc/nginx/nginx.conf

我重新启动了nginx几次,以确保上述更改得到反映。
下面是试图访问目录时浏览器的快照。

你能建议一下吗?

ki0zmccv

ki0zmccv1#

我把location /npm-logs/ {改成了location /npm-logs {。尾随的/是为了让它失败。

相关问题