Last active
June 21, 2023 22:54
-
-
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)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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