後述の設定において、
bash
1curl http://127.0.0.1/test -v
とすると、
bash
1< HTTP/1.1 301 Moved Permanently 2< Server: nginx/1.14.0 (Ubuntu) 3< Date: Sun, 07 Mar 2021 08:25:19 GMT 4< Content-Type: text/html 5< Content-Length: 194 6< Location: http://127.0.0.1/test/ 7< Connection: keep-alive
と301を返します。
/test
がlocationディレクティブによって
/var/www/html/tmp
に置換され、
/var/www/html/tmpはディレクトリなので読み込みできず、403を返却すると想定しましたので、なぜ301を返却するかが分かりません。
よろしくお願いいたします。
bash
1$ pwd 2/var/www/html 3 4$ ls -l 5total 908 6-rw-r--r-- 1 root root 612 avril 4 2020 index.nginx-debian.html 7drwxr-xr-x 2 root root 4096 mars 7 09:18 tmp
nginx
1server { 2 listen 80 default_server; 3 listen [::]:80 default_server; 4 5 root /var/www/html; 6 7 index index.html index.htm index.nginx-debian.html; 8 9 server_name _; 10 11 location / { 12 try_files $uri $uri/ =404; 13 } 14 15 location /test { 16 alias /var/www/html/tmp; 17 } 18}
あなたの回答
tips
プレビュー