Skip to main content
Level 2
Dec 17, 2024 5:21 PM UTC

Add the Forwarded-Host header

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.

7 replies

daniel-strmecki
Adobe Champion, Community Advisor, UG Leader
Adobe Champion, Community Advisor, UG Leader
Dec 17, 2024 8:15 PM UTC

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

Translate
Level 2
Dec 17, 2024 9:15 PM UTC

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

Translate
daniel-strmecki
Adobe Champion, Community Advisor, UG Leader
Adobe Champion, Community Advisor, UG Leader
Dec 17, 2024 10:27 PM UTC

@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

Translate
kautuk_sahni
Level 9
Jan 7, 2025 10:44 AM UTC

@evertonsa2 Did you find the suggestion helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!

Translate
Kautuk Sahni