Skip to content

server.port=8443 without SSL redirects login to 8080 #6140

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
fmarot opened this issue Jun 10, 2016 · 11 comments
Closed

server.port=8443 without SSL redirects login to 8080 #6140

fmarot opened this issue Jun 10, 2016 · 11 comments
Labels
status: invalid An issue that we don't feel is valid

Comments

@fmarot
Copy link

fmarot commented Jun 10, 2016

Hello,
I face a problem in my everyday job app that I have been able to reproduce easily in the official sample "spring-boot-sample-web-secure-custom" ( https://github.com/spring-projects/spring-boot/tree/master/spring-boot-samples/spring-boot-sample-web-secure-custom ).

In application.properties, if I set server.port=8443 (while keeping classic http protocol, no https at all), then when I try to open url http://127.0.0.1:8443/FOOBAR then I am redirected to url http://127.0.0.1:8080/login (see the port has changed !)

Any port other than 8443 seems to be fine.
As 443 is the HTTP_S_ port, there must be something hardcoded with 8443 somewhere.

In my own app, configuring https solves the problem. But I'd like users to be able to switch to http if they want without knowing that they also have to use a port other than 8443.

Thanks for the good job Spring Boot Team !

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Jun 10, 2016
@philwebb philwebb added the for: team-attention An issue we'd like other members of the team to review label Jun 10, 2016
@philwebb
Copy link
Member

/cc @rwinch

@philwebb philwebb removed the for: team-attention An issue we'd like other members of the team to review label Jun 22, 2016
@rwinch
Copy link
Member

rwinch commented Jun 22, 2016

@fmarot Thank you for the feedback.

This is due to Spring Security's PortResolverImpl which attempts to work around a well know IE bug. From the javadoc:

This class is capable of handling the IE bug which results in an incorrect URL being
presented in the header subsequent to a redirect to a different scheme and port where
the port is not a well-known number (ie 80 or 443). Handling involves detecting an
incorrect response from ServletRequest.getServerPort() for the scheme (eg
a HTTP request on 8443) and then determining the real server port (eg HTTP request is
really on 8080). The map of valid ports is obtained from the configured
PortMapper

If you want to use HTTP, the easiest solution is to select a port other than 8443 which is typically used for HTTPS and thus remapped to work around the IE bug.

@wilkinsona
Copy link
Member

Thanks, @rwinch

@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid and removed status: waiting-for-triage An issue we've not yet triaged labels Jun 22, 2016
@swaminagesh
Copy link

fmarot please wirte how u configure https to solve the problem of 8443 as soon as possible please please.
thank u so much in advance.

@barrycommins
Copy link

Hi,

I ran into the inverse of this problem, where I had configured ssl, but hadn't changed the default server.port from 8080

In this case, redirections go to port 8443.
I put together a little project to demonstrate it: https://github.com/barrycommins/spring-boot-ssl-redirect-bug

I understand this this is due to the IE bug, but it may be worth documenting that if you enable ssl that you need to change the value for server.port to something other than the default.

@jmatzen
Copy link

jmatzen commented May 9, 2018

Yup I'm having the same issue. I'm constrained by a broken OAuth2 redirect config that I have no control over.

@hauntingEcho
Copy link

I just ran into this issue as well (with HTTPS configured to 8080) - log errors/warnings would be helpful if this case is triggered

@wilkinsona
Copy link
Member

it may be worth documenting that if you enable ssl that you need to change the value for server.port to something other than the default.

It's a little more complicated than that as it only becomes a problem if you're also using Spring Security.

log errors/warnings would be helpful if this case is triggered

This is an interesting suggestion, but I think any change would be more broadly applicable if it was made in Spring Security. There's nothing Spring Boot-specific about the behaviour.

@dtitov
Copy link

dtitov commented Mar 18, 2020

Why this issue is marked as invalid? I'm running into the same issue as the others above: I have configured Spring to work over SSL on 8080 port, but for some weird reason, I'm being redirected to 8443. I tried everything: overriding PortMappers, customizing Connectors - nothing helps. IMHO, this is a hell of a valid issue and it needs to be fixed... :-/

@dtitov
Copy link

dtitov commented Mar 18, 2020

I have created an issue here: spring-projects/spring-security#8140

@miomip
Copy link

miomip commented Nov 16, 2022

I have the same problem, but I found when I stopped the server and the Ide I use the problem is there still when nothing is running. I don't understand how that happens.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests