Multiple Sites: What is the Best Method?

Hello Everyone,

I am experimenting with using the Sites functionality to present 2 different microsites to 2 different audiences.

I have followed the OpenCraft Configuring multiple sites on the Open edX platform just got easier. | OpenCraft and official guidelines 4.2.2. Configuring Sites Independently — Installing, Configuring, and Running the Open edX Platform documentation and came up with the following settings:

{
    "PLATFORM_NAME": "NYUSH 1",
    "platform_name": "NYUSH 1",
    "SITE_NAME": "nyush1.example.com",
    "site_domain": "nyush1.example.com",
    "SESSION_COOKIE_DOMAIN": "nyush1.example.com",
    "course_org_filter": "nyush1"
}

I also created A records to point nyush1.example.com towards the server IP.

I initially encountered problems with HTTPS and Allowed Hosts at this point, so I created the following plugin to add the new domains to the Caddyfile and ALLOWED_HOSTS variable.

"""
Plugin to add microsites to CADDY.

{{ LMS_HOST }}{$default_site_port}, {{ PREVIEW_LMS_HOST }}{$default_site_port} {
    @favicon_matcher {
        path_regexp ^/favicon.ico$
    }
    rewrite @favicon_matcher /theming/asset/images/favicon.ico

    # Limit profile image upload size
    request_body /api/profile_images/*/*/upload {
        max_size 1MB
    }
    request_body {
        max_size 4MB
    }

    import proxy "lms:8000"

    {{ patch("caddyfile-lms")|indent(4) }}
}

"""
from tutor import hooks

# Adjust these websites
site_list_input = ["nyush1.example.com", "nyush2.example.com"]

site_list_formatted = []
for site in site_list_input:
	site += "{$default_site_port}"
	site_list_formatted.append(site)

site_list = ", ".join(site_list_formatted)


microsites = "\n" + site_list + """ { 
    @favicon_matcher {
      path_regexp ^/favicon.ico$
    }
    rewrite @favicon_matcher /theming/asset/images/favicon.ico

    # Limit profile image upload size
    request_body /api/profile_images/*/*/upload {
        max_size 1MB
    }

    request_body {
        max_size 4MB
    }

    import proxy "lms:8000"

    tls {
      dns cloudflare
    }
}
"""

allowed_hosts_extension = "ALLOWED_HOSTS += " + str(site_list_input)

caddyfile = ("caddyfile", microsites)

allowed_hosts = ("openedx-lms-production-settings", allowed_hosts_extension)

hooks.Filters.ENV_PATCHES.add_items([caddyfile, allowed_hosts])

The plugin part felt a little convoluted, so I am wondering whether there is a better way to handle the Sites.

Can you please share if you have a better method?

Thank you.

I am having a problem with implementing OAUTH login using this method.

The same provider works for the main Site A, however, stuck in a 302 redirect loop when used with another Site B instead. The user does log in after going back to the main page, but that is less than ideal.

The URL after login looks like this: https://LMS_B/auth/complete/google-oauth2/?

Has anyone encountered this issue before?