Add support for using RemoteSpringApplication behind a proxy
This commit adds two new properties, spring.devtools.remote.proxy.host and spring.devtools.remote.proxy.port that can be used to configure RemoteSpringApplication to connect to the remote application through an HTTP proxy. Closes gh-3968
This commit is contained in:
parent
0c2f281e89
commit
434d46f583
|
@ -50,6 +50,8 @@ public class RemoteDevToolsProperties {
|
|||
|
||||
private Debug debug = new Debug();
|
||||
|
||||
private Proxy proxy = new Proxy();
|
||||
|
||||
public String getContextPath() {
|
||||
return this.contextPath;
|
||||
}
|
||||
|
@ -82,6 +84,10 @@ public class RemoteDevToolsProperties {
|
|||
return this.debug;
|
||||
}
|
||||
|
||||
public Proxy getProxy() {
|
||||
return this.proxy;
|
||||
}
|
||||
|
||||
public static class Restart {
|
||||
|
||||
/**
|
||||
|
@ -131,4 +137,34 @@ public class RemoteDevToolsProperties {
|
|||
|
||||
}
|
||||
|
||||
public static class Proxy {
|
||||
|
||||
/**
|
||||
* The host of the proxy to use to connect to the remote application.
|
||||
*/
|
||||
private String host;
|
||||
|
||||
/**
|
||||
* The port of the proxy to use to connect to the remote application.
|
||||
*/
|
||||
private Integer port;
|
||||
|
||||
public String getHost() {
|
||||
return this.host;
|
||||
}
|
||||
|
||||
public void setHost(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
public Integer getPort() {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
public void setPort(Integer port) {
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -16,6 +16,8 @@
|
|||
|
||||
package org.springframework.boot.devtools.remote.client;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.Proxy.Type;
|
||||
import java.net.URL;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
@ -37,6 +39,7 @@ import org.springframework.boot.devtools.autoconfigure.DevToolsProperties;
|
|||
import org.springframework.boot.devtools.autoconfigure.DevToolsProperties.Restart;
|
||||
import org.springframework.boot.devtools.autoconfigure.OptionalLiveReloadServer;
|
||||
import org.springframework.boot.devtools.autoconfigure.RemoteDevToolsProperties;
|
||||
import org.springframework.boot.devtools.autoconfigure.RemoteDevToolsProperties.Proxy;
|
||||
import org.springframework.boot.devtools.autoconfigure.TriggerFileFilter;
|
||||
import org.springframework.boot.devtools.classpath.ClassPathChangedEvent;
|
||||
import org.springframework.boot.devtools.classpath.ClassPathFileSystemWatcher;
|
||||
|
@ -91,8 +94,13 @@ public class RemoteClientConfiguration {
|
|||
public ClientHttpRequestFactory clientHttpRequestFactory() {
|
||||
List<ClientHttpRequestInterceptor> interceptors = Arrays
|
||||
.asList(getSecurityInterceptor());
|
||||
return new InterceptingClientHttpRequestFactory(
|
||||
new SimpleClientHttpRequestFactory(), interceptors);
|
||||
SimpleClientHttpRequestFactory requestFactory = new SimpleClientHttpRequestFactory();
|
||||
Proxy proxy = this.properties.getRemote().getProxy();
|
||||
if (proxy.getHost() != null && proxy.getPort() != null) {
|
||||
requestFactory.setProxy(new java.net.Proxy(Type.HTTP, new InetSocketAddress(
|
||||
proxy.getHost(), proxy.getPort())));
|
||||
}
|
||||
return new InterceptingClientHttpRequestFactory(requestFactory, interceptors);
|
||||
}
|
||||
|
||||
private ClientHttpRequestInterceptor getSecurityInterceptor() {
|
||||
|
|
|
@ -674,6 +674,8 @@ content into your application; rather pick only the properties that you need.
|
|||
spring.devtools.remote.context-path=/.~~spring-boot!~ # context path used to handle the remote connection
|
||||
spring.devtools.remote.debug.enabled=true # enable remote debug support
|
||||
spring.devtools.remote.debug.local-port=8000 # local remote debug server port
|
||||
spring.devtools.remote.proxy.host= # the host of the proxy to use to connect to the remote application
|
||||
spring.devtools.remote.proxy.port= # the port of the proxy to use to connect to the remote application
|
||||
spring.devtools.remote.restart.enabled=true # enable remote restart
|
||||
spring.devtools.remote.secret= # a shared secret required to establish a connection
|
||||
spring.devtools.remote.secret-header-name=X-AUTH-TOKEN # HTTP header used to transfer the shared secret
|
||||
|
|
|
@ -1064,6 +1064,9 @@ property is read and passed to the server for authentication.
|
|||
TIP: It's always advisable to use `https://` as the connection protocol so that traffic is
|
||||
encrypted and passwords cannot be intercepted.
|
||||
|
||||
TIP: If you need to use a proxy to access the remote application, configure the
|
||||
`spring.devtools.remote.proxy.host` and `spring.devtools.remote.proxy.port` properties.
|
||||
|
||||
|
||||
|
||||
[[using-boot-devtools-remote-update]]
|
||||
|
|
Loading…
Reference in New Issue