We're updating the issue view to help you get more done. 

Support X-Forwarded-Proto header in ResponseUtils.baseURL

Description

https://github.com/geoserver/geoserver/blob/master/src/ows/src/main/java/org/geoserver/ows/util/ResponseUtils.java#L427
ResponseUtils.baseURL use req.getScheme() but if tomcat run http and run inside SSL proxy server, req.getScheme() return "http".
This problem raise mix-contents error in Layer Preview in Style Editor.
This problem will resolve to check "X-Forwarded-Proto" header.

example:

1 2 3 4 5 6 7 8 String scheme = req.getScheme(); String proto = req.getHeader("x-forwarded-proto"); StringBuffer sb = new StringBuffer(); if (proto.equals("https") && !scheme.equals(proto)) { sb.append(proto); } else { sb.append(scheme); }

nginx config example:

1 2 3 4 5 6 location ~* ^/geoserver/(.*) { proxy_set_header X-Forwarded-Proto https; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://127.0.0.1:8080; }

Environment

Ubuntu 16.04 + nginx + tomcat8

Status

Assignee

Unassigned

Reporter

Taro Matsuzawa

Triage

Fix versions

Affects versions

2.11.1

Priority

Medium