mirror of
https://github.com/YunoHost-Apps/leed_ynh.git
synced 2024-09-03 19:26:32 +02:00
Fix alias_traversal
This commit is contained in:
parent
379cfa3446
commit
3d45ac88c7
5 changed files with 29 additions and 4 deletions
|
@ -1,4 +1,5 @@
|
|||
location __PATH__ {
|
||||
#sub_path_only rewrite ^__PATH__$ __PATH__/ permanent;
|
||||
location __PATH__/ {
|
||||
alias __FINALPATH__/ ;
|
||||
if ($scheme = http) {
|
||||
rewrite ^ https://$server_name$request_uri? permanent;
|
||||
|
|
|
@ -454,6 +454,11 @@ EOF
|
|||
ynh_store_file_checksum "$finalfail2banfilterconf"
|
||||
|
||||
sudo systemctl restart fail2ban
|
||||
if local fail2ban_error="$(tail -n50 /var/log/fail2ban.log | grep "WARNING Command.*$app.*addfailregex")"
|
||||
then
|
||||
echo "[ERR] Fail2ban fail to load the jail for $app" >&2
|
||||
echo "WARNING${fail2ban_error#*WARNING}" >&2
|
||||
fi
|
||||
}
|
||||
|
||||
# Remove the dedicated fail2ban config (jail and filter conf files)
|
||||
|
|
|
@ -68,9 +68,20 @@ then
|
|||
# Make a backup of the original nginx config file if modified
|
||||
ynh_backup_if_checksum_is_different "$nginx_conf_path"
|
||||
|
||||
# Replace locations starting with old_path
|
||||
# Look for every location possible patterns (see https://nginx.org/en/docs/http/ngx_http_core_module.html#location)
|
||||
ynh_replace_string "location\( \(=\|~\|~\*\|\^~\)\)\? $old_path" "location\1 $new_path" "$nginx_conf_path"
|
||||
# Move from sub path to root
|
||||
if [ "$new_path" == "/" ]
|
||||
then
|
||||
ynh_replace_string "^.*rewrite.*\^$old_path" "#sub_path_only&" "$nginx_conf_path"
|
||||
|
||||
ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path" "$nginx_conf_path"
|
||||
|
||||
# Move to a sub path
|
||||
else
|
||||
ynh_replace_string "^#sub_path_only" "" "$nginx_conf_path"
|
||||
ynh_replace_string "\(rewrite *\^\)$old_path\$ $old_path/*" "\1$new_path$ $new_path/" "$nginx_conf_path"
|
||||
fi
|
||||
|
||||
ynh_replace_string "location ${old_path%/}/" "location ${new_path%/}/" "$nginx_conf_path"
|
||||
|
||||
# Calculate and store the nginx config file checksum
|
||||
ynh_store_file_checksum "$nginx_conf_path"
|
||||
|
|
|
@ -72,6 +72,10 @@ ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie d
|
|||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
if [ "$path_url" != "/" ]
|
||||
then
|
||||
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
|
||||
fi
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
|
|
|
@ -92,6 +92,10 @@ ynh_setup_source "$final_path" # Télécharge la source, décompresse et copie d
|
|||
# NGINX CONFIGURATION
|
||||
#=================================================
|
||||
|
||||
if [ "$path_url" != "/" ]
|
||||
then
|
||||
ynh_replace_string "^#sub_path_only" "" "../conf/nginx.conf"
|
||||
fi
|
||||
ynh_add_nginx_config
|
||||
|
||||
#=================================================
|
||||
|
|
Loading…
Reference in a new issue