Skip to content

HowTo: Subdomains

Holger Hees edited this page Feb 4, 2020 · 5 revisions

How to register a subdomain

If you register a subdomain, automatically all available authentication methods, like openid connect (if configured), form based login and basic auth, are enabled for this subdomain.

For details about the authentication methods check the main feature description

Ansible task definition

- name: copy apache vhost
  vars:
    sub_domain: "mysubdomain"
    include: "templates/etc/apache2/_.ansible.vhost.d/mysubdomain.inc"
  import_tasks: roles/apache/tasks/add_vhost.yml

Subdomain config file mysubdomain.inc

Which defines a document root to {{htdocs_path}}mysubdomain/ and a proxy to an additional service running on http://127.0.0.1:8080/ which is available behind the url path /proxy.

DocumentRoot "{{htdocs_path}}mysubdomain/"

<Directory {{htdocs_path}}mysubdomain/>
    Options +FollowSymLinks -SymLinksIfOwnerMatch +MultiViews
    AllowOverride None
</Directory>

<Location /proxy>
  ProxyPass http://127.0.0.1:8080/
  ProxyPreserveHost on
  RequestHeader set X-Forwarded-Proto "https" env=HTTPS
</Location>

Available URLs

This configuration enables the following urls.

https://mysubdomain.<yourservername>/
https://mysubdomain.<yourservername>/proxy/

To force other authentication methods

https://fa-mysubdomain.<yourservername>/
https://fa-mysubdomain.<yourservername>/proxy/
https://ba-mysubdomain.<yourservername>/
https://ba-mysubdomain.<yourservername>/proxy/