feat: serve styled mirror directories with nginx fancyindex
This commit is contained in:
@@ -3,11 +3,56 @@ server {
|
||||
server_name 100.69.2.2;
|
||||
client_max_body_size 5m;
|
||||
|
||||
location = /mirrors {
|
||||
return 302 /;
|
||||
}
|
||||
location = /mirrors/ {
|
||||
return 302 /;
|
||||
}
|
||||
|
||||
location /assets/ {
|
||||
root /opt/mirrorouc/current/dist;
|
||||
try_files $uri =404;
|
||||
add_header X-Content-Type-Options nosniff always;
|
||||
}
|
||||
|
||||
# Fancyindex renders the complete directory on the server. No Go/JSON hop.
|
||||
location ~ ^/mirrors/(?<mirror_directory>.+/)$ {
|
||||
alias /data/mirrors/$mirror_directory;
|
||||
index .mirrorouc-autoindex-only;
|
||||
fancyindex on;
|
||||
fancyindex_header /_directory/header.html;
|
||||
fancyindex_footer /_directory/footer.html;
|
||||
fancyindex_show_path off;
|
||||
fancyindex_name_length 256;
|
||||
fancyindex_exact_size off;
|
||||
fancyindex_directories_first on;
|
||||
fancyindex_show_dotfiles off;
|
||||
fancyindex_localtime off;
|
||||
fancyindex_time_format "%Y-%m-%d %H:%M:%S UTC";
|
||||
include /opt/mirrorouc/current/dist/fancy-index/labels.conf;
|
||||
charset utf-8;
|
||||
limit_except GET { deny all; }
|
||||
add_header Cache-Control no-cache;
|
||||
add_header X-Content-Type-Options nosniff always;
|
||||
add_header X-Frame-Options DENY always;
|
||||
add_header Referrer-Policy same-origin always;
|
||||
add_header Content-Security-Policy "default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data: https:; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'" always;
|
||||
}
|
||||
|
||||
# Only Fancyindex subrequests may read the generated fragments.
|
||||
location = /_directory/header.html {
|
||||
internal;
|
||||
alias /opt/mirrorouc/current/dist/fancy-index/header.html;
|
||||
}
|
||||
location = /_directory/footer.html {
|
||||
internal;
|
||||
alias /opt/mirrorouc/current/dist/fancy-index/footer.html;
|
||||
}
|
||||
|
||||
location /mirrors/ {
|
||||
alias /data/mirrors/;
|
||||
autoindex on;
|
||||
autoindex_exact_size off;
|
||||
autoindex_localtime on;
|
||||
autoindex off;
|
||||
add_header X-Content-Type-Options nosniff always;
|
||||
add_header Content-Security-Policy "sandbox; default-src 'none'; style-src 'unsafe-inline'; img-src 'self' data:" always;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user