Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

SOLVED

Enabled Vhost and Available Vhosts - AEM ignoring all vhosts if default.vhost is present

Avatar

Level 6

Hi All,

 

I am having a strange issue in my dispatcher configurations -

I have one vhost in both enabled and available folders - xBrandA.vhost.

 

Scenario 1 - Both default.vhost and xBrandA.vhost are present as symlinks in enabled vhosts folder

URL - https://brandA.com/content/brandA/us/en/home.html

Response Headers - x-vhost is publish - This is coming from default.vhost

Here the x-vhost was expected to be xBrandA as the domain should have mapped to the corresponding vhost.

 

Scenario 2 - Only xBrandA.vhost is present as symlink in enabled vhosts folder

URL - https://brandA.com/content/brandA/us/en/home.html

Response Headers - x-vhost is xBrandA - This is coming from xBrandA .vhost

 

But in this scenario the publish URL is displaying "It Works!" as the default.vhost has ServerName "publish" and ServerAlias "*".

 

I want to have both vhosts work in parallel - default.vhost works for publish based URLs (https://publish-p22222-e111111.adobeaemcloud.com/) and xBrandA.vhost for brandA.com.

 

Workaround - If I rename the "default.vhost" to "zzz_default.vhost", that works correctly as the order in which requests are mapped to vhosts changes - default.vhost being the last one.

But ideally there should not have been any need of renaming this file.

 

@arunpatidar , @Mohit_KBansal@Jörg_Hoh - Any help on the above issue ?

 

Thanks,

Rohan Garg

1 Accepted Solution

Avatar

Correct answer by
Level 6

Update - The order in which vhost are called have an impact on how the request is handled.

Renaming the default.vhost to zzz_default.vhost ensured that this vhost file with ServerAlias * was called last.

This allowed my custom vhost file XBrandA.vhost to be called first and handle URL correctly.

 

Query - if the order in which vhost are called is important and default.vhost has ServerAlias *, how can we ensure that default.vhost is called at the last ? (assuming we don't change the name to zzz_default.vhost and want to retain the original name)

 

Update - I have removed the default.vhost from my repo, replaced it with publish.vhost - Changed the ServerAlias from "*" to "adobeaemcloud.com". This will ensure that not all requests are served by publish.vhost but only those from publish adobeaemcloud.com.

Why default.vhost is getting picked over custom vhost file is still unknown in this.

View solution in original post

5 Replies

Avatar

Correct answer by
Level 6

Update - The order in which vhost are called have an impact on how the request is handled.

Renaming the default.vhost to zzz_default.vhost ensured that this vhost file with ServerAlias * was called last.

This allowed my custom vhost file XBrandA.vhost to be called first and handle URL correctly.

 

Query - if the order in which vhost are called is important and default.vhost has ServerAlias *, how can we ensure that default.vhost is called at the last ? (assuming we don't change the name to zzz_default.vhost and want to retain the original name)

 

Update - I have removed the default.vhost from my repo, replaced it with publish.vhost - Changed the ServerAlias from "*" to "adobeaemcloud.com". This will ensure that not all requests are served by publish.vhost but only those from publish adobeaemcloud.com.

Why default.vhost is getting picked over custom vhost file is still unknown in this.

Avatar

Level 6

@Shiv_Prakash_Patel - As per the link https://github.com/aemgeeks1212/geeksdispatcher/tree/MAC/conf.d/available_vhosts 

The default.vhost has below configuration -

 

<VirtualHost *:80>
ServerName we-retail.local
# Put names of which domains are used for your published site/content here
ServerAlias we-retail.local
# Use a document root that matches the one in conf.dispatcher.d/default.farm

DocumentRoot "/private/var/www/content/we-retail"

 

Is this the default.vhost which is generated by AEM's Dispatcher module ?

My default.vhost has ServerName "publish" and ServerAlias "*"

Ideally this should not be overwritten. If I change/remove the ServerAlias that would solve the problem but then again default.vhost should not be modified.

Avatar

Level 4

Hi @Rohan_Garg ,

No, the default Vhost will have ServerName "publish" and ServerAlias "*" only.

 

Avatar

Level 6

Then is it mandatory to have default.vhost as part of enabled vhosts ?

I checked the WKND Repo at URL - https://github.com/adobe/aem-guides-wknd/tree/main/dispatcher/src/conf.d/enabled_vhosts

The default.vhost is not mandatory to be there.

There is already a catch-all vhost as part of dispatcher_vhost.conf as seen below -

https://github.com/adobe/aem-guides-wknd/blob/main/dispatcher/src/conf.d/dispatcher_vhost.conf

 

<VirtualHost *:80>
ServerName unmatched-host-catch-all

ServerAlias "*"

 

I have currently removed default.vhost and replaced it with publish.vhost and changed ServerAlias to "*.aemcloud.com" to filter Publish URLs.