Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.sun.enterprise.config.serverbeans.Domain;
import com.sun.enterprise.config.serverbeans.SecureAdmin;
import com.sun.enterprise.config.serverbeans.SecurityService;
import com.sun.enterprise.config.serverbeans.Server;
import com.sun.enterprise.security.SecurityContext;
import com.sun.enterprise.security.auth.realm.Realm;
import com.sun.enterprise.security.auth.realm.exceptions.NoSuchUserException;
Expand Down Expand Up @@ -322,7 +323,14 @@ public String getRemoteHost() {
* When enabled, the server trusts X-Real-IP and X-Forwarded-For headers.
*/
private boolean isBehindProxyEnabled() {
Config config = domain.getServerNamed("server").getConfig();
// find the <server> element of the current instance. Needed if executed on non-DAS instances,
// e.g. when calling admin commands against a remote instance
Server server = domain.getServerNamed(serverEnv.getInstanceName());
Config config;
if (server == null || (config = server.getConfig()) == null) {
// seems not possible.
throw new IllegalStateException("Can't find the config of the server.");
}
Protocol protocol = config.getAdminListener().findHttpProtocol();
Http http = protocol != null ? protocol.getHttp() : null;
return http != null && http.isBehindProxy();
Expand Down
Loading