Expand my Community achievements bar.

Add the Forwarded-Host header

Avatar

Level 2

How can I add the Forwarded-Host header?
For security reasons, I need to add the Forwarded-Host header to my website, but I have no idea how to implement this.
In the file called rewrite.rules I added the code (dispatcher > conf.d > rewrites > rewrite.rules):

<IfModule mod_headers.c>
    RequestHeader set Forwarded-Host "%{Host}e" env=Host
</IfModule>

But it didn't solve my problem of adding the Forwarded-Host.
3 Replies

Avatar

Level 9

Hi @EvertonSa2,

rewrite rules are added in the mod_rewrite section of your VHOST file. Add your custom header directly under VirtualHost in the VHOST file. For example:

 

# Add Forwarded-Host header
RequestHeader set Forwarded-Host "%{HTTP_HOST}e"

 

 

Good luck,

Daniel

Avatar

Level 2

Mas em qual arquivo exatamente eu adiciono esse trecho de código: 

# Add Forwarded-Host header
RequestHeader set Forwarded-Host "%{HTTP_HOST}e"

Não posso modificar o arquivo default.vhost, porque se eu modifica-lo a pipeline da erro.
Os arquivos que possuo são:
dispatcher > src > conf.d > enabled_vhosts > default.vhost
dispatcher > src > conf.d > enabled_vhosts > custom_headers.conf

dispatcher > src > conf.d > available_vhosts > default.vhost
dispatcher > src > conf.d > rewrites > default_rewrite.rules
dispatcher > src > conf.d > rewrites > rewrite.rules

Avatar

Level 9

@EvertonSa2 let's please stick to English, so I dont have to Google Translate your question

You should create your own VHOST file, not edit the default one. It is clearly stated in the AEM archetype: https://github.com/adobe/aem-project-archetype/blob/develop/src/main/archetype/dispatcher.cloud/src/...

Also, you did not mention if you are using AEM on Prem or AEMaaCS. Please refer to the relevant Dispatcher documentation from Adobe. Both are well documented.

 

Good luck,

Daniel