Disable user interface and admin for domain with my_webapp (SOLVED, including hook script)

What type of hardware are you using: VPS bought online
What YunoHost version are you running: 12.0.11
What app is this about: my_webapp

Describe your issue

I have multiple domains, say example.com and example.org. On one of them, say example.org I have installed a my_webapp and made it default for that domain. Now I want to remove both /yunohost/sso and /yunohost/admin from working on example.org but keep it as usual on example.com and any other domains.

So I commented these lines as follows at the end of /etc/nginx/conf.d/example.org.conf:

    #include /etc/nginx/conf.d/yunohost_sso.conf.inc;
    #include /etc/nginx/conf.d/yunohost_admin.conf.inc;
    #include /etc/nginx/conf.d/yunohost_api.conf.inc;

and that seems to work fine. (After I figured out that I should do it for both the main domain and it’s www. alias. :wink:)

Is this a reasonable configuration / should I have done it differently?

Would it be possible (or: how difficult) to make this a configurable option for the my_webapp?

Lastly, can/should I also disable this one?

    access_by_lua_file /usr/share/ssowat/access.lua

:right_arrow: BETTER solution using a hook :hook:

The better way to do this seems to be a hook but I still need to find better documentation about that.. :slight_smile:

The following script goes into /etc/yunohost/hooks.d/conf_regen/90-remove-ynh-from-some-domains.sh.

#!/bin/bash

action=$1
pending_dir=$4

# only continue if we are in the "pre" step
[[ "$action" == "pre" ]] || exit 0

domain_list=(
  "example.org"
  "example.com"
  "www.example.org"
  "www.example.com"
)

for domain in "${domain_list[@]}"; do
    nginx_conf=$pending_dir/../nginx/etc/nginx/conf.d/$domain.conf
    # quit if file does not exist
    [[ -e $nginx_conf ]] || exit 0
    # remove these lines:
    sed -i \
        -e '\@include /etc/nginx/conf.d/yunohost_sso.conf.inc;@d' \
        -e '\@include /etc/nginx/conf.d/yunohost_admin.conf.inc;@d' \
        -e '\@include /etc/nginx/conf.d/yunohost_api.conf.inc;@d' \
        -e '\@include /etc/nginx/conf.d/yunohost_http_errors.conf.inc;@d' \
        $nginx_conf
done

UPDATE: Changed to NOT remove the line'access_by_lua_file /usr/share/ssowat/access.lua;`because that is also needed to make redirects work.

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.