stephanediondev / elasticsearch-admin

Web administration for Elasticsearch (2.x to 8.x): cluster, nodes, indices, shards, index templates, repositories, snapshots ...
https://stephanediondev.github.io/elasticsearch-admin/
MIT License
90 stars 10 forks source link

Support X-Forwarded-Proto header #67

Closed sviridovdy closed 10 months ago

sviridovdy commented 1 year ago

Hi, is there a way to support X-Forwarded-Proto header when generating response HTML that contains form element? Specifically I mean to use matching scheme in action attribute. We have this app running behind load balancer/proxy that is doing SSL termination and we are facing problems that even though web site is loaded over https action attribute on form elements has http:// scheme.

stephanediondev commented 10 months ago

Hi

I found another solution.

The attribute "action" on tag "form" was forced to current request URI. But with a proxy you've got the application URL behind, not the browser URL.

Now the attribute "action" is removed, that means submit will be done to the current browser URL.

Tested in local with Nginx https://aaa sending to Apache http://bbb

Commit https://github.com/stephanediondev/elasticsearch-admin/commit/4a87493620f17bd4c73baad001e697ebd3f8ef4b

Release https://github.com/stephanediondev/elasticsearch-admin/releases/tag/v1.77

sviridovdy commented 10 months ago

I deployed this new version and it works as expected. Thank you for this fix. As a note until this fix was released we used to modify config/packages/framework.yaml file by adding

# the IP address (or range) of your proxy    
trusted_proxies: '127.0.0.1,REMOTE_ADDR'
# trust *all* "X-Forwarded-*" headers
trusted_headers: ['x-forwarded-for', 'x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-port', 'x-forwarded-prefix']