Want to access Spring Boot Service without port in URL - spring

For example
https://192.168.1.136:8081/ works fine
But if I try to access
https://192.168.1.136/ Error - The site can't be reached.
What are the ways to access it without a port in URL?

Assign port 80 instead of 8081 will work.
Update application.properties in /src/main/resources/ with
server.port=80
Alternatively you may also set server.port as system property using command line option to jvm -Dserver.port=80

Related

Running Spring Boot application but Jenkins hijacks the port

I am following the IntelliJ "Hello World" Spring Boot tutorial (https://www.youtube.com/watch?v=5kOGdZmpSDI) and when I run the application it sets up the Tomcat server on port 8080, as expected, but when I go to localhost:8080 the Jenkins login page will appear instead as it was previously ran in a Docker container.
Is there a way to check what is running on Tomcat or a way to remove Jenkins entirely?
I have already deleted all running containers and images on Docker desktop and uninstalled Docker, but this issue still persists.
Any help would be appreciated as I am new to using Spring Boot as well as Docker - thank you.
By default springboot uses port 8080,you can change the port from 8080 to someother port,you can configure this in your application.properties file
Server.port= anyportnumber
I think this is the one you are looking for!,,Hope this helps

port number of server in log file name - log4j2

Is there any way to configure log-file to be appended with the port number of application-server.
Example: if my spring boot web service is running on 5001 port, then the log file name must be appended with the port number.
Port number is not configured in application.yml file.
Also, I tried using lookup ${spring:server.port} from application.yml file, but it does not seem to work.
I found a post on stack overflow where it says, log4j2 lookup works with Spring cloud config. I don't want to use cloud config.
Another post says to use higher version of log4j2 ie at least 2.13. But this also didn't work.
You can set your port no in application.properties file and after that u can read that using Environment Object.
In application.properties :- server.port= 5001
In Log4j implementation class :-
#Autowired
Environment env;
String keyVal = env.getProperty("server.port");
And append this port to your Log4j file name.

Changing Default Ports in Moqui

Moqui Framework Version : 2.1.3
The Framework runs on the default port 8080 just fine, i would like to change the default ports and i did read https://www.moqui.org/m/docs/framework/Run+and+Deploy#a2.RuntimeDirectoryandMoquiConfigurationXMLFile
which states > "Each of these can be system environment variables (with underscores) or Java properties (with underscores or dots) using the -D command-line argument.
i did find the webapp_ variables are referenced in MoquiDefaultConf.xml as mentioned in the above material and tried using the below start command >
$sudo nohup java -Dwebapp_http_host=localhost -Dwebapp_http_port=9080 -Dwebapp_https_port=9443 -jar moqui.war conf=conf/MoquiDevConf.xml &
However the above command does not seem to change the port, Moqui is still running on default port 8080, What could i be missing?
I also tried the solution to update the webapp tag in MoquiDevConf.xml as mentioned in Running Moqui on Tomcat over SSL (setting http-port and htts-port) - return code 302 with no joy,
Appreciate any pointers, i'm really stuck
The environment variables or Java properties you mention are for setting the ports to use when building URLs. These are the external ports used for accessing your server and if a load balancer or reverse proxy is used may be different from the ports the servlet container is running on. For more information see:
https://moqui.org/m/docs/framework/Run+and+Deploy#EnvironmentVariables
If you are running Moqui with the embedded Jetty server you can specify the port it listens on using the port argument as described in the Executable WAR File section of the Run and Deploy document:
https://moqui.org/m/docs/framework/Run+and+Deploy#a3.ExecutableWARFile
Note that the embedded Jetty server can be used in production but it does not support https and is meant to be used behind a reverse proxy like nginx or Apache httpd that forwards requests to the embedded Jetty server.
If you deploy the WAR file by dropping it in a Servlet Container (ie as an actual WAR file, not treating it as an executable JAR file) then the port configuration would be done with the Servlet Container (Tomcat, Jetty, etc).

Where to specify a specific port number in spring boot service file in systemd?

Need to know where can I specify the spring boot port aa when I check my service status I get this:
"Serverkt.log started at server-name with process id"
But I don't get the port number.
Also wanted to know where I can find the spring logs in the server
spring boot has its configuration file. I guess that you have it included in your jar/war file. So basically unzip that file and look inside it (try to search for application.properties or application.yaml|yml).
property server.port defines the port on which application is running. It defaults to 8080.
If you are using spring-boot 2 then with property logging.path you can change the path where output file will be placed. However I don't know if this works when you have logback/log4j/... configuration.
if you run your application you can override those properties specified in appplication.properties|yaml by providing command line properties. For example you can change the port with command java -jar your-boot.jar --server.port=9090
Since you're starting spring boot from a service file, you can set the port using command line arguments e.g.port 8083 would look like this:
ExecStart=/usr/bin/java -jar /opt/corda/spring.jar --server.port=8083

How to change Port of Apache ACE?

I want to change the port of Apache ACE to 80. How can I do that? I could not find any documentation for that. I have tried by changing value of key Dorg.osgi.service.http.port in file platform.properties from 8080 to 80. But after this, i am not able to login in Apache ace. It gives invalid username & password message. However, i am able to login through same credentials if i run it on port 8080.
The properties in following files needs to be updated for port change.
platform.properties
-Dorg.osgi.service.http.port
conf/org.apache.ace.webui.vaadin.cfg
aceHost
obrUrl
conf/org.apache.ace.server.activation.impl.cfg
hostName
obrUrl
conf/org.apache.ace.discovery.property.cfg
serverURL
conf/org.apache.ace.deployment.provider.repositorybased.cfg
url
conf/org.apache.ace.configurator.useradmin.task.UpdateUserAdminTask.cfg
repositoryLocation
conf/org.apache.ace.client.automation.cfg
hostName
conf/org.apache.ace.activation.matcher.cfg
repositoryURL
In current release (1.0.0) you can achieve what you were initially trying by removing following lines from laucher.properties that resides inside server(-allinone).jar
org.apache.ace.server.port=8080
org.osgi.service.http.port=8080
With 1.0.0 I was not able to pass in parameters via -D (which were commented out previously).
What worked for me was setting port numbers in server-allinone.jar/launcher.properties.
With Ace 1.0, we used command line properties to change the port (to 8083 in our case):
java -Dorg.apache.ace.server.port=8083 -Dorg.osgi.service.http.port=8083 -jar server-allinone.jar
This did not work any more with Ace 2.0.1, ie we could change the port but authentication would not work. I identified the properties to be changed in launcher.properties but set them on the command line instead of changing launcher.properties. This keeps from having to recreate the jar. The command line I use is:
java -Dorg.apache.ace.server=localhost:8083 -Dorg.osgi.service.http.port=8083 -Dorg.apache.ace.obr=localhost:8083 -jar server-allinone.jar

Resources