Is it possible to use one fully qualified domain name (FQDN) for multiple websites?
While Jahia supports one FQDN per website, it is possible to workaround that thanks to the use of URL rewrite rules at the front-end and Jahia levels BUT before going on this road, you should consider the following:
The current scenario:
Steps to follow:
defaults
log global
mode http
option httplog
option dontlognull
option httpclose
retries 3
timeout connect 300
timeout client 1200s
timeout server 1200s
option http-server-close
option forwardfor
frontend http_front
bind *:80
redirect scheme https code 301 if !{ ssl_fc }
frontend https_front
bind *:443 ssl crt /etc/haproxy/key_and_cert.pem
reqadd X-Forwarded-Proto:\ https
default_backend https_back
#Production v1.0.16
#dns list
acl dns_www.company1.com hdr(host) -i www.company1.com
acl dns_www.company2.com hdr(host) -i www.company2.com
acl rootpath path_reg ^/$|^/global/$|^/global/..$
#language
acl language_en req.fhdr(accept-language),language(fr;en) -m str en
acl language_fr req.fhdr(accept-language),language(fr;en) -m str fr
#/modules/forms
acl forms path_reg ^/.*modules/forms/.*$
#redirect back
#redirects to company1 corporate website
http-request redirect code 301 location https://www.company1.com/global/fr/ if dns_www.company1.com rootpath language_fr
http-request redirect code 301 location https://www.company1.com/global/en/ if dns_www.company1.com rootpath
#http-request replace-uri ^/([a-z]{2})/sites/company1_([^/]+)(/.*)$ /\2/\1\3 if dns_www.company1.com
#http-request replace-uri ^/([a-z]{2})/sites/company1_([^/]+)(/.*)$ /global/en/home/about/ if dns_www.company1.com
#redirects to company2 corporate website
http-request redirect code 301 location https://www.company2.com/global/fr/ if dns_www.company2.com rootpath language_fr
http-request redirect code 301 location https://www.company2.com/global/en/ if dns_www.company2.com rootpath
#rewrites maybe use http-request set-path
http-request replace-uri ^/(?!cms)(.*?)/([a-z]{2})/(.*) /\2/sites/company1_\1/home/\3 if dns_www.company1.com
http-request replace-uri ^/(?!cms)(.*?)/([a-z]{2})/(.*) /\2/sites/company2_\1/home/\3 if dns_www.company2.com
#set header for using right template
acl site_company1 hdr(host) -i www.company1.com
acl site_company2 hdr(host) -i www.company2.com
http-request set-header shared-site company1 if site_company1
http-request set-header shared-site company2 if site_company2
## Header sub-site
http-request set-header sub-site %[capture.req.uri] if !forms
http-request set-header sub-site %[hdr(referer)] if forms
http-request replace-header sub-site ^https?://[^/]*(/[^/]*/[^/]*/.*)$ \1 if forms
http-request replace-header sub-site ^/([^/]*)/?.*$ \1
## Header language
http-request set-header sub-site-language %[capture.req.uri] if !forms
http-request set-header sub-site-language %[hdr(referer)] if forms
http-request replace-header sub-site-language ^https?://[^/]*(/[^/]*/[^/]*/.*)$ \1 if forms
http-request replace-header sub-site-language ^/[^/]*/?([^/]*)/?.*$ \1
## Set the header host in order to activate the SEO for the correct website
http-request set-header Host %[req.hdr(sub-site)].company1.com if dns_www.company1.com !forms
http-request set-header Host %[req.hdr(sub-site)].company2.com if dns_www.company2.com !forms
backend https_back
compression algo gzip
compression type text/plain text/css text/js text/xml text/javascript application/javascript application/json application/xml application/rss image/svg text/html
server jahia1 127.0.0.1:8080 check fall 1 rise 1 inter 2s
balance leastconn
http-request set-header X-Forwarded-Port %[dst_port]
http-request add-header X-Forwarded-Proto https if { ssl_fc }
http-request add-header X-CLIENT-IP %[src]
Known issues: