Skip to content

Commit

Permalink
Fix httpd config for X-Forwarded-Proto
Browse files Browse the repository at this point in the history
  • Loading branch information
mumesan committed Jan 3, 2025
1 parent 6e7951e commit 6b9721e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 4 additions & 2 deletions templates/ironicapi/config/ironic-api-httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,16 @@ CustomLog /dev/stdout proxy env=forwarded
Require all granted
</Directory>

{{- if $vhost.TLS }}
{{- if $vhost.TLS }}
SetEnvIf X-Forwarded-Proto https HTTPS=1

## SSL directives
SSLEngine on
SSLCertificateFile "{{ $vhost.SSLCertificateFile }}"
SSLCertificateKeyFile "{{ $vhost.SSLCertificateKeyFile }}"
{{- end }}
{{- else }}
SetEnvIf X-Forwarded-Proto http HTTPS=0
{{- end }}

## WSGI configuration
WSGIApplicationGroup %{GLOBAL}
Expand Down
14 changes: 10 additions & 4 deletions templates/ironicinspector/config/httpd.conf
Original file line number Diff line number Diff line change
Expand Up @@ -30,22 +30,28 @@ CustomLog /dev/stdout proxy env=forwarded
ServerName {{ $vhost.ServerName }}

## Request header rules
## as per http://httpd.apache.org/docs/2.2/mod/mod_headers.html#requestheader
RequestHeader set X-Forwarded-Proto "https"
## as per http://httpd.apache.org/docs/2.4/mod/mod_headers.html#requestheader
{{- if $vhost.TLS }}
RequestHeader setIfEmpty X-Forwarded-Proto "https"
{{- else }}
RequestHeader setIfEmpty X-Forwarded-Proto "http"
{{- end }}

## Proxy rules
ProxyRequests Off
ProxyPreserveHost Off
ProxyPass / http://localhost:5051/ retry=10
ProxyPassReverse / http://localhost:5051/

{{- if $vhost.TLS }}
{{- if $vhost.TLS }}
SetEnvIf X-Forwarded-Proto https HTTPS=1

## SSL directives
SSLEngine on
SSLCertificateFile "{{ $vhost.SSLCertificateFile }}"
SSLCertificateKeyFile "{{ $vhost.SSLCertificateKeyFile }}"
{{- end }}
{{- else }}
SetEnvIf X-Forwarded-Proto http HTTPS=0
{{- end }}
</VirtualHost>
{{ end }}

0 comments on commit 6b9721e

Please sign in to comment.