mirror of
https://github.com/YunoHost-Apps/hotspot_ynh.git
synced 2024-09-03 19:25:53 +02:00
nginx template for redirect to admin
This commit is contained in:
parent
ad18f8dc68
commit
6f2275a93a
2 changed files with 9 additions and 14 deletions
6
conf/nginx.conf
Normal file
6
conf/nginx.conf
Normal file
|
@ -0,0 +1,6 @@
|
|||
location / {
|
||||
if ($remote_addr ~ "^__IP4_NAT_PREFIX__.\d+$") {
|
||||
return 302 __CAPTIVE_PORTAL_URL__;
|
||||
}
|
||||
return 302 https://$http_host/yunohost/admin;
|
||||
}
|
|
@ -199,22 +199,11 @@ ynh_app_config_apply() {
|
|||
|
||||
# Activate captive portal or not
|
||||
captive_portal=$(ynh_app_setting_get --app=$app --key=captive_portal)
|
||||
if [[ "$captive_portal" == '1' ]]
|
||||
then
|
||||
echo "location / {" > /etc/nginx/conf.d/default.d/redirect_to_admin.conf
|
||||
|
||||
echo " if (\$remote_addr ~ "^$ip4_nat_prefix.\d+$") {" >> /etc/nginx/conf.d/default.d/redirect_to_admin.conf
|
||||
|
||||
echo " return 302 $captive_portal_url;" >> /etc/nginx/conf.d/default.d/redirect_to_admin.conf
|
||||
|
||||
echo " }" > /etc/nginx/conf.d/default.d/redirect_to_admin.conf
|
||||
|
||||
echo " return 302 https://\$http_host/yunohost/admin;" >> /etc/nginx/conf.d/default.d/redirect_to_admin.conf
|
||||
|
||||
echo "}" >> /etc/nginx/conf.d/default.d/redirect_to_admin.conf
|
||||
systemctl reload nginx
|
||||
if [[ "${captive_portal}" -eq 1 ]]; then
|
||||
ynh_config_add_nginx
|
||||
ynh_systemd_action --service_name=captiveportal_fakedns --action="start" --log_path=systemd
|
||||
else
|
||||
ynh_config_remove_nginx
|
||||
ynh_systemd_action --service_name=captiveportal_fakedns --action="stop" --log_path=systemd
|
||||
fi
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue