Skip to content
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

Enhancement: Allow to specify protocol for URLs the server sends to the client #24918

Closed
OndroMih opened this issue Apr 16, 2024 · 0 comments · Fixed by #25044
Closed

Enhancement: Allow to specify protocol for URLs the server sends to the client #24918

OndroMih opened this issue Apr 16, 2024 · 0 comments · Fixed by #25044
Labels
enhancement New feature or request
Milestone

Comments

@OndroMih
Copy link
Contributor

Environment Details

  • GlassFish 7.0.14
  • JDK version: Any
  • OS: Any
  • Database: N/A

Background (motivation)

URLs generated by GlassFish take into consideration the value of the Server Name configuration value in config -> Network Config -> Protocols -> (listener) -> HTTP. When Server Name is set, its value (including port number if specified) will be used instead of localhost in generated URLs. The generated URLs now always retain the protocol (HTTP or HTTPS) used by the listener.

In case when GlassFish is behind a proxy server, where the proxy server communicates with the outside world via HTTPS, and GlassFish communicates with the proxy via plain HTTP inside an internal network, GlassFish should generate URLs to respect how outside world communicates with the proxy, including using HTTPS in the URL. This doesn't happen now, it's only possible to create URLs with a custom domain and port, but not with a custom protocol. The URLs always start with http:// and there's no way to turn them into https:// in GlassFish.

An example:

Enhancement Description

Add a configuration option for the HTTP protocol, e.g. Server Protocol (to be in line with Server Name), which allows to change the protocol used in the generated URLs. So that if HTTPS is specified, the URL will use the https:// protocol.

Alternatively, allow using the protocol in the Server Name value, so that it could be https://mydomain.com:443". Currently, the protocol is stripped from the value of "Server Name" and the value is changed to just mydomain.com:443`.

Steps to reproduce

  1. Deploy a simple application, e.g. with a html page. Set context root to /myapp.
  2. Configure Server Name for the http-listener-1 to mydomain.com:443
  3. Open http://localhost:8080/myapp in a browser (8080 is the port of the http-listener-1)
  4. The browser will redirect to http://mydomain.com:443/myapp/ (which will end with "The connection was reset" which is expected)

image

With the enhancement and proper configuration, in point 4, the browser would redirect to https://mydomain.com/myapp/

Impact of Issue

Simpler and safer configuration of a proxy server as a load balancer for a GlassFish cluster.

Type: Enhancement
Component: Network
Priority: Normal

OndroMih added a commit to OndroMih/glassfish that referenced this issue Jul 12, 2024
OndroMih added a commit to OndroMih/glassfish that referenced this issue Jul 12, 2024
@dmatej dmatej added this to the 7.0.16 milestone Jul 15, 2024
@dmatej dmatej added the enhancement New feature or request label Jul 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
2 participants