前提・実現したいこと
nginxでDirectoryIndexみたいのをhtml上で表示したい。
このように実装したいと思っています。
html
1 2<html> 3<head> 4<title>TESTPAGE</title> 5</head> 6 7<br>TEST<br/> 8[index.htmlがあるフォルダーのディレクトリを表示(選択してそのファイルを直リンクで開く)] 9 10</body> 11</html>
初心者でお手数ですが、よろしくお願いします。
追記
http://b.fcsys.org/2015/07/enable-customization-index-page-for-nginx.html
こちらのサイトを参考にしてみたのですが、 https://imgur.com/a/5jAjBEw 404 Not Foundと表示されてしまいます。ファイルはしっかりセットしてあります。 https://imgur.com/a/OdoSUUL
config
1## 2# You should look at the following URL's in order to grasp a solid understanding 3# of Nginx configuration files in order to fully unleash the power of Nginx. 4# http://wiki.nginx.org/Pitfalls 5# http://wiki.nginx.org/QuickStart 6# http://wiki.nginx.org/Configuration 7# 8# Generally, you will want to move this file somewhere, and start with a clean 9# file but keep this around for reference. Or just disable in sites-enabled. 10# 11# Please see /usr/share/doc/nginx-doc/examples/ for more detailed examples. 12## 13 14# Default server configuration 15# 16server { 17 listen 80 default_server; 18 listen [::]:80 default_server; 19 20 # SSL configuration 21 # 22 # listen 443 ssl default_server; 23 # listen [::]:443 ssl default_server; 24 # 25 # Note: You should disable gzip for SSL traffic. 26 # See: https://bugs.debian.org/773332 27 # 28 # Read up on ssl_ciphers to ensure a secure configuration. 29 # See: https://bugs.debian.org/765782 30 # 31 # Self signed certs generated by the ssl-cert package 32 # Don't use them in a production server! 33 # 34 # include snippets/snakeoil.conf; 35 36 root /var/www/html; 37 38 # Add index.php to the list if you are using PHP 39 index index.html index.htm index.nginx-debian.html; 40 41 server_name _; 42 43 location / { 44 # First attempt to serve request as file, then 45 # as directory, then fall back to displaying a 404. 46 try_files $uri $uri/ =404; 47 fancyindex on; # Enable FuncyIndex 48 fancyindex_exact_size off; # off: Use GB / MB / KB etc. 49 fancyindex_localtime on; # on: Use server local time 50 fancyindex_header /etc/nginx/header.html; # Customization Header Code 51 fancyindex_footer /etc/nginx/footer.html; # Customization Footer Code 52 } 53 54 # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000 55 # 56 #location ~ .php$ { 57 # include snippets/fastcgi-php.conf; 58 # 59 # # With php7.0-cgi alone: 60 # fastcgi_pass 127.0.0.1:9000; 61 # # With php7.0-fpm: 62 # fastcgi_pass unix:/run/php/php7.0-fpm.sock; 63 #} 64 65 # deny access to .htaccess files, if Apache's document root 66 # concurs with nginx's one 67 # 68 #location ~ /.ht { 69 # deny all; 70 #} 71} 72 73 74# Virtual Host configuration for example.com 75# 76# You can move that to a different file under sites-available/ and symlink that 77# to sites-enabled/ to enable it. 78# 79#server { 80# listen 80; 81# listen [::]:80; 82# 83# server_name example.com; 84# 85# root /var/www/example.com; 86# index index.html; 87# 88# location / { 89# try_files $uri $uri/ =404; 90# } 91#} 92
追記
絶対URLで入力しましたがエラーは変わりませんでした。