In application.yml, I need to config https port and http port.
For this, code is as follows in application.properties.
server.port.http=80
server.port.https=443
In application.yml, I tried follwing code for configuration,
but it doesn't work.
code1
server:
port: 443
http: 80
code2
server:
port:
http: 80
port: 443
How do this only with application.yml?
I can do it with collaboration of .properties and .yml.
However, I want to do this with only application.yml.
Solution
I found solution thanks to answer of dariosicily.
I configured https and http port as follows.
server:
port: 443
ports:
https: 443
http: 8080
I need to configure default port of spring boot.
So, I configured default port using server.port=443,
and https and http port using server.ports.
And used them in java as follows.
#Value("${server.ports.http}")
private int serverPortHttp;
#Value("${server.ports.https}")
private int serverPortHttps;
It works really well. Thank you!!!
You can configure both http and https ports creating a dictionary with http and https keys in your application.yml :
server:
port:
http: 8080
https: 443
Then you can access both properties in your java class (or kotlin with an equivalent code) :
#Value("${server.port.http}")
private int httpPort;
#Value("${server.port.https}")
private int httpsPort;
Related
Is it still possible to change the actuator port in 2.3.4?
neither management.port nor management.endpoints.port seems to work. Intellij doesn't recognize any of these settings, either.
It is management.server.port. Customizing the Management Server Port
With these settings:
server:
port: 8082
management:
server:
port: 8081
the default app port is 8082 and the actuator data is exposed at 8081
I'm using Thorntail 2.3.0.Final, in documentation "5.4.2. Sockets" there is an example of configuring some kind of something:
thorntail:
network:
socket-binding-groups:
standard-sockets:
http:
port: 8081
I thought it starts listening on port 8081, but it persistently continues start listening port 8080
so how to configure port binding properly?
The shortcut way is to use:
thorntail:
http:
port: 8081
Actually, it is not a problem, but a strange thing I would like to understand. I use SpringBoot2 with embedded Tomcat. And I've added self-signed SSL certificate. This is pretty usual config:
server.ssl.key-store-type=PKCS12
server.ssl.key-store=classpath:keystore.p12
server.ssl.key-store-password=123456
server.ssl.key-alias=tomcat
server.port=8443
And I made a connector, to force http -> https redirect, like in many examples:
private Connector getHttpConnector() {
Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
connector.setScheme("http");
connector.setPort(8080);
connector.setSecure(false);
connector.setRedirectPort(8443);
return connector;
}
If I would not specify server.port property in my config, I will see the following error:
Description:
The Tomcat connector configured to listen on port 8080 failed to
start. The port may already be in use or the connector may be
misconfigured.
Action:
Verify the connector's configuration, identify and stop any process
that's listening on port 8080, or configure this application to listen
on another port.
But if I will, I will see following:
o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat started on port(s):
8443 (https) 8080 (http) with context path ''
Why server.port starts to point at https port??? Even sources of springframework.boot.autoconfigure.web.ServerProperties says that it is
/**
* Server HTTP port.
*/
Is it ok, or I've got something strange in my server? Or this is how Conectors works? :) Thank you
By default, the embedded server start on port 8080 if you don't give any value for server.port in the properties file
And you are also specifying connectors port as 8080 (connector.setPort(8080);)
Hence you are getting port conflicts.
Configured Nginx to interact with Tomcat on port 9090 on mac.
This configuration works when querying on localhost. Fails to work when connecting from outside, until firewall is disabled.
I have firewall configuration to something like below for forwarding to port 8080 and 8443
sudo ipfw add 100 fwd 127.0.0.1,8080 tcp from any to me 80
sudo ipfw add 110 fwd 127.0.0.1,8443 tcp from any to me 443
Request domain.com --> 443 --> nginx on 8443 --> Tomcat 9090
Side note:
domain.com --> 80 --> re-directs to 443 and then to nginx on 8443 --> Tomcat 9090
iOS Firewall IPFW sends everything from 80 to 8080 and 443 to 8443
Nginx is running on 8080 and 8443
Nginx redirects everything from 8080 to 8443. Nginx on 8443 communicates with Tomcat over 9090.
Tomcat is on 9090
Router is configured to allow access on Port 80 and 443,
So the question, what do I need to change on mac to unblock firewall for a successful
response.
I downloaded JHipster from git and tried to understand how to configure session timeout but couldn't find any web.xml or java-based class for that.
Could you please help me figure out how can I configure session timeout for example to be 20 min?
This is a Spring Boot configuration.
You can configure it in your application-*.yml file:
server:
port: 8080
address: localhost
sessionTimeout: 20000
in your application-*.yml file:
server:
port: 8080
address: localhost
sessionTimeout: 20000
is OK for 20 minutes but if you want to have more 30 minutes your access Token validity ("tokenValidityInSeconds" attribute) is 30 minutes by default. You can configue this attribute in application.yml file.
Example for 3 hours = 180 minutes = 10800 secondes:
authentication:
oauth:
clientid: testspsyapp
secret: mySecretOAuthSecret
# Token is valid 3 hours
tokenValidityInSeconds: 10800
Do not to forget the changes "sessionTimeout" attribut to your application-*.yml file :)
server:
port: 8080
address: localhost
sessionTimeout: 180000
I know this is an old question but the answer needed to be updated as the config setting being called is deprecated. You'll want to use this instead.
server:
port: 8080
servlet:
session:
timeout: 60s