Expand my Community achievements bar.

SOLVED

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

Avatar

Community Advisor

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
Community Advisor

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

6 Replies

Avatar

Correct answer by
Community Advisor

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

Community Advisor

@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

Community Advisor

Hi @Rohan_Garg ,

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

 

Shiv Prakash

Avatar

Community Advisor

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.

Avatar

Level 1

I will suggest, instead of modifying the default.vhost file, you can create your vhost file by giving the name starting from a number. i.e. 01_myvhostfile.vhost

 

This will enable you to control the ordering of all the vhost files if you have multiple.

 

 

And what I understand from the scenario 2, where its showing it work's. You are missing the dispatcher configuration inside your vhost file.