Securing Eureka Server connection exception. com.sun.jersey.api.client.ClientHandlerException












0















I'm having an issue with securing Eureka and my Config server before I put it into production. It's a fairly basic system and should work but Eureka throws me an exception after running. It only shows when I enable Spring Boot Security but runs fine without it. com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused (Connection refused)



Here are my config files:



ConfigServer application.yml



server:
port: 8888

spring:
cloud:
config:
server:
git:
uri: https://github.com/starrynights89/spring-social-config-server
security:
user:
name: user
password: password


bootstrap.yml for Eureka



spring:
application:
name: eureka
cloud:
config:
label: session
password: password


Eureka application.yml



server:
port: 8761

eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://user:password@${eureka.instance.hostname}:${server.port}/eureka/


ConfigServer.java



package com.alexander.springsocial;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.context.annotation.Bean;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@SpringBootApplication
@EnableConfigServer
public class SpringSocialConfigServer {

public static void main(String args) {
SpringApplication.run(SpringSocialConfigServer.class, args);
}

@Bean
UserDetailsService userDetailsService() {
return new InMemoryUserDetailsManager(
User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER").build());
}
}


EurekaServer.java



package com.alexander.springsocial;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@SpringBootApplication
@EnableEurekaServer
public class SpringSocialEurekaServerApplication {

public static void main(String args) {
SpringApplication.run(SpringSocialEurekaServerApplication.class, args);
}

@Bean
UserDetailsService userDetailsService() {
return new InMemoryUserDetailsManager(
User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER").build());
}

@Configuration
protected static class SecurityPolicy extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.httpBasic()
.and()
.csrf().disable();
}
}
}


One other strange aspect is that Eureka server runs on port 8080 even though the .yml file specifies port 8761:



bug



Any help or pointers would be appreciated!










share|improve this question























  • Some of my testing has fixed part of the issue. If I disable security on the config server Eureka boots correctly to port 8761. So for some reason I can't explain why securing the config server breaks Eureka.

    – starrynights89
    Nov 25 '18 at 2:36


















0















I'm having an issue with securing Eureka and my Config server before I put it into production. It's a fairly basic system and should work but Eureka throws me an exception after running. It only shows when I enable Spring Boot Security but runs fine without it. com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused (Connection refused)



Here are my config files:



ConfigServer application.yml



server:
port: 8888

spring:
cloud:
config:
server:
git:
uri: https://github.com/starrynights89/spring-social-config-server
security:
user:
name: user
password: password


bootstrap.yml for Eureka



spring:
application:
name: eureka
cloud:
config:
label: session
password: password


Eureka application.yml



server:
port: 8761

eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://user:password@${eureka.instance.hostname}:${server.port}/eureka/


ConfigServer.java



package com.alexander.springsocial;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.context.annotation.Bean;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@SpringBootApplication
@EnableConfigServer
public class SpringSocialConfigServer {

public static void main(String args) {
SpringApplication.run(SpringSocialConfigServer.class, args);
}

@Bean
UserDetailsService userDetailsService() {
return new InMemoryUserDetailsManager(
User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER").build());
}
}


EurekaServer.java



package com.alexander.springsocial;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@SpringBootApplication
@EnableEurekaServer
public class SpringSocialEurekaServerApplication {

public static void main(String args) {
SpringApplication.run(SpringSocialEurekaServerApplication.class, args);
}

@Bean
UserDetailsService userDetailsService() {
return new InMemoryUserDetailsManager(
User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER").build());
}

@Configuration
protected static class SecurityPolicy extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.httpBasic()
.and()
.csrf().disable();
}
}
}


One other strange aspect is that Eureka server runs on port 8080 even though the .yml file specifies port 8761:



bug



Any help or pointers would be appreciated!










share|improve this question























  • Some of my testing has fixed part of the issue. If I disable security on the config server Eureka boots correctly to port 8761. So for some reason I can't explain why securing the config server breaks Eureka.

    – starrynights89
    Nov 25 '18 at 2:36
















0












0








0








I'm having an issue with securing Eureka and my Config server before I put it into production. It's a fairly basic system and should work but Eureka throws me an exception after running. It only shows when I enable Spring Boot Security but runs fine without it. com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused (Connection refused)



Here are my config files:



ConfigServer application.yml



server:
port: 8888

spring:
cloud:
config:
server:
git:
uri: https://github.com/starrynights89/spring-social-config-server
security:
user:
name: user
password: password


bootstrap.yml for Eureka



spring:
application:
name: eureka
cloud:
config:
label: session
password: password


Eureka application.yml



server:
port: 8761

eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://user:password@${eureka.instance.hostname}:${server.port}/eureka/


ConfigServer.java



package com.alexander.springsocial;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.context.annotation.Bean;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@SpringBootApplication
@EnableConfigServer
public class SpringSocialConfigServer {

public static void main(String args) {
SpringApplication.run(SpringSocialConfigServer.class, args);
}

@Bean
UserDetailsService userDetailsService() {
return new InMemoryUserDetailsManager(
User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER").build());
}
}


EurekaServer.java



package com.alexander.springsocial;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@SpringBootApplication
@EnableEurekaServer
public class SpringSocialEurekaServerApplication {

public static void main(String args) {
SpringApplication.run(SpringSocialEurekaServerApplication.class, args);
}

@Bean
UserDetailsService userDetailsService() {
return new InMemoryUserDetailsManager(
User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER").build());
}

@Configuration
protected static class SecurityPolicy extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.httpBasic()
.and()
.csrf().disable();
}
}
}


One other strange aspect is that Eureka server runs on port 8080 even though the .yml file specifies port 8761:



bug



Any help or pointers would be appreciated!










share|improve this question














I'm having an issue with securing Eureka and my Config server before I put it into production. It's a fairly basic system and should work but Eureka throws me an exception after running. It only shows when I enable Spring Boot Security but runs fine without it. com.sun.jersey.api.client.ClientHandlerException: java.net.ConnectException: Connection refused (Connection refused)



Here are my config files:



ConfigServer application.yml



server:
port: 8888

spring:
cloud:
config:
server:
git:
uri: https://github.com/starrynights89/spring-social-config-server
security:
user:
name: user
password: password


bootstrap.yml for Eureka



spring:
application:
name: eureka
cloud:
config:
label: session
password: password


Eureka application.yml



server:
port: 8761

eureka:
instance:
hostname: localhost
client:
registerWithEureka: false
fetchRegistry: false
serviceUrl:
defaultZone: http://user:password@${eureka.instance.hostname}:${server.port}/eureka/


ConfigServer.java



package com.alexander.springsocial;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.config.server.EnableConfigServer;
import org.springframework.context.annotation.Bean;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@SpringBootApplication
@EnableConfigServer
public class SpringSocialConfigServer {

public static void main(String args) {
SpringApplication.run(SpringSocialConfigServer.class, args);
}

@Bean
UserDetailsService userDetailsService() {
return new InMemoryUserDetailsManager(
User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER").build());
}
}


EurekaServer.java



package com.alexander.springsocial;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cloud.netflix.eureka.server.EnableEurekaServer;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;
import org.springframework.security.core.userdetails.User;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.provisioning.InMemoryUserDetailsManager;

@SpringBootApplication
@EnableEurekaServer
public class SpringSocialEurekaServerApplication {

public static void main(String args) {
SpringApplication.run(SpringSocialEurekaServerApplication.class, args);
}

@Bean
UserDetailsService userDetailsService() {
return new InMemoryUserDetailsManager(
User.withDefaultPasswordEncoder()
.username("user")
.password("password")
.roles("USER").build());
}

@Configuration
protected static class SecurityPolicy extends WebSecurityConfigurerAdapter {

@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.anyRequest().authenticated()
.and()
.httpBasic()
.and()
.csrf().disable();
}
}
}


One other strange aspect is that Eureka server runs on port 8080 even though the .yml file specifies port 8761:



bug



Any help or pointers would be appreciated!







spring spring-security configserver eureka






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 20 '18 at 4:25









starrynights89starrynights89

2417




2417













  • Some of my testing has fixed part of the issue. If I disable security on the config server Eureka boots correctly to port 8761. So for some reason I can't explain why securing the config server breaks Eureka.

    – starrynights89
    Nov 25 '18 at 2:36





















  • Some of my testing has fixed part of the issue. If I disable security on the config server Eureka boots correctly to port 8761. So for some reason I can't explain why securing the config server breaks Eureka.

    – starrynights89
    Nov 25 '18 at 2:36



















Some of my testing has fixed part of the issue. If I disable security on the config server Eureka boots correctly to port 8761. So for some reason I can't explain why securing the config server breaks Eureka.

– starrynights89
Nov 25 '18 at 2:36







Some of my testing has fixed part of the issue. If I disable security on the config server Eureka boots correctly to port 8761. So for some reason I can't explain why securing the config server breaks Eureka.

– starrynights89
Nov 25 '18 at 2:36














0






active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386213%2fsecuring-eureka-server-connection-exception-com-sun-jersey-api-client-clienthan%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























0






active

oldest

votes








0






active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53386213%2fsecuring-eureka-server-connection-exception-com-sun-jersey-api-client-clienthan%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?