Skip to content

Instantly share code, notes, and snippets.

@EpicKiwi
Last active June 21, 2023 22:54
Show Gist options
  • Save EpicKiwi/82eab0d17af2aa3ecb2a7c5bba811500 to your computer and use it in GitHub Desktop.
Save EpicKiwi/82eab0d17af2aa3ecb2a7c5bba811500 to your computer and use it in GitHub Desktop.
NGINX configuration allowing user to create their own personal space under a subdomain with partial DAV support (here under .kiwibox.local)
server {
listen 80;
listen [::]:80;
server_name ~^(?<user>.+)\.kiwibox\.local$;
root /home/$user/$user.kiwibox.local;
try_files $uri $uri/ =404;
client_body_temp_path /tmp/nginx-dav-tmp;
dav_methods PUT DELETE MKCOL COPY MOVE;
create_full_put_path on;
dav_access group:rw all:r;
index index.html index.htm;
set $forbidden 1;
location ~ /\. {
auth_pam "Espace privé";
auth_pam_service_name "nginx";
}
location / {
limit_except GET POST {
auth_pam "Opération restreinte";
auth_pam_service_name "nginx";
}
}
if ( $remote_user = "" ){
set $forbidden 0;
}
if ( $remote_user = $user ){
set $forbidden 0;
}
if ( $forbidden ){
return 403;
}
location @404 {
try_files 404.html =404;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment