Specifying an http proxy with spring-boot

前端 未结 4 2162
没有蜡笔的小新
没有蜡笔的小新 2021-01-03 00:08

How do I specify a http proxy to use when running a spring-boot fat war as a tomcat server?

I have tried the following which is not working.

java -ja         


        
相关标签:
4条回答
  • 2021-01-03 00:28

    You may configure all property of REMOTE DEVTOOLS (RemoteDevToolsProperties) in application.properties.

    spring.devtools.remote.context-path=  # Context path used to handle the remote connection.
    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 # Whether to enable remote restart.
    spring.devtools.remote.secret= # A shared secret required to establish a connection (required to enable remote support).  
    spring.devtools.remote.secret-header-name=X-AUTH-TOKEN # HTTP header used to transfer the shared secret.
    
    0 讨论(0)
  • 2021-01-03 00:31

    I've found that I need -Dhttps.proxySet=true in order for the proxy config to actually be used.

    0 讨论(0)
  • 2021-01-03 00:39

    Put the JVM options before -jar. This should work:

    java -Dhttp.proxyHost=localhost -Dhttp.proxyPort=3128 -Dhttps.proxyHost=localhost -Dhttps.proxyPort=3128 -jar my-application.war

    Explanation

    According to java command-line documentation, the command's syntax is:

    java [ options ] -jar file.jar [ arguments ]

    The arguments are the args that'll be received in your main(String[] args). So, it's totally your responsibility to use them somehow. And if you forward them to spring using SpringApplication.run(MyApplication.class, args);, then you need to find documentation that says how spring uses args in the run method.

    The options, however, are not sent to your app. One of their uses is to set what java calls system properties using -Dproperty=value. According to Java Networking and Proxies, setting, e.g., http.proxyHost property makes the JVM proxy all your http request through that host.

    0 讨论(0)
  • 2021-01-03 00:42

    need to add for authenticating proxy server

    -Dhttp.proxyUser=**username**
    -Dhttp.proxyPassword=**password**
    
    0 讨论(0)
提交回复
热议问题