How to change the localhost:8080 to www.myWebApp.com? - java

Every time I access my spring boot application I type localhost:8080.
I want to access the application by typing www.MyApp.com. It is an in-house application so it is not going to be live on the Web. The application is using spring boot embedded. Is there a way to change it?

This is more related to operating system's host configurations.
https://www.webhosting.uk.com/kb/how-to-update-hosts-file-entry-on-windows-ubuntu-and-mac/
About the adding port number in host file
refer: Using port number in Windows host file

Related

spring.cloud.kubernetes.discovery.discovery-server-url - what is the correct url?

I am just setting two simple services on Mac using minikube
I have the service set up and I can access it via ingress / minikube tunnel . So i know the service works
I am using Spring Boot 3, with the so i need to specify the spring-cloud-starter-kubernetes-all package. This means I need to specify a url for spring.cloud.kubernetes.discovery.discovery-server-url
When i try to do the simple call to
discoveryClient.getServices()
I get the error "Connection refused https://kubernetes.docker.internal:6443/apps"
"apps" is my second service
It is refusing connection to the value of spring.cloud.kubernetes.discovery.discovery-server-url
At the moment i have this set to spring.cloud.kubernetes.discovery.discovery-server-url=https://kubernetes.docker.internal:6443
I am assuming this is incorrect and I need some help as to what is the correct url to set this to / or the correct place to find this. I thought this would be the internal url.
You are trying to configure your discovery client with the Kubernetes API server URL, which is incorrect.
Your client application needs to be connected to Spring Cloud Kubernetes Discovery Server.
It's an independent application that will work like a proxy between your client SpringBoot apps and Kubernetes.
You can find its images here: https://hub.docker.com/r/springcloud/spring-cloud-kubernetes-discoveryserver/tags
And it should be deployed to Kubernetes via yaml file.
Then you can configure
spring.cloud.kubernetes.discovery.discovery-server-url
with this discovery server URL. That URL will most likely come from a Kubernetes service that you will create for the discovery server application.
Please, find the full deployment YAML and the related documentation here:
https://spring.io/blog/2021/10/26/new-features-for-spring-cloud-kubernetes-in-spring-cloud-2021-0-0-m3
Please, let us know how that goes

Question on Spring Boot + Azure Listening Port

I am a spring boot starter and a cloud starter, and I deploy my spring boot project (Rest API) in Azure via App Service (Using Intellij Plugin Azure ToolKit).
When I get my deploy url which is like https://DOMAIN.azurewebsites.net, I am curious why I can fetch my data without typing :8080 PORT. I don't add the server.port=8080 in my application.properties.
Usually, if you are deploying your spring boot project in a Linux instance (Both AWS EC2 and Azure VM), and you can get your data by typing: http://<YOUR_LINUX_PUBLIC_IP>:8000
I try to get my data by both https://DOMAIN.azurewebsites.net and http://.azurewebsites.net, and they all work.
However, if I try: https://****.azurewebsites.net:8000, it shows I can not access this URL. Is Azure applying my Spring Boot Service to both HTTPS and HTTP port by default?
Web Apps don't have a port-mapping feature. The only ports open for Web Apps are 80 and 443.
https://DOMAIN.azurewebsites.net:443
http://DOMAIN.azurewebsites.net:80
Traffic Manager does not provide port-mapping. You'd need to run your own proxy for handling this.
So we can't specify 8080 port in Web Apps. If you need that control, you can use Cloud Services or Virtual Machines.
Refer to this answer.

how can i directly access my web application deployed in aws tomcat using domain without showing port?

I Want to access my web application in the Amazon Web Service directly through my URL like Service.com but I am using tomcat so, I have to write port number with name Service.com:8090/Login.
Even if I set my port to 80 it will open the tomcat manager page.
There are two possibilities for accessing your Application.
1- if you have deployed your application on AWS Elastic Beanstalk (Tomcat Beanstalk) then it will automatically route your application on Port 80 (default port for HTTP), you just need to configure route53 or can directly access the application via Beanstalk URL
2- if you have deployed manually, then you have to set a Loadblancer which will route from 80 to 8080.
Reference Link for Setting up Loadblancer:-
https://docs.aws.amazon.com/elasticloadbalancing/latest/classic/elb-getting-started.html
While setting up Loadblancer your Instance Port will be 8080 and make sure your Inbound rule (Security Group) is configured Properly.

Linking Tomcat to MYSQL on Openshift

I've a java web application running on openshift 3 online.
I'm rather new to this platform and not familiar to the usage of service and pods.
So currently i have 2 containers running.
A. Web app
B. MYSQL
I've created environment variables to supply the MYSQL username,password,port and ip-address to the container A running the web application. However, it seem like when openshift creates a new pod, the ip-address changes. Is there any other way i could link the two container so that i don't have to rely on the ip-address?
Each service has a name/domain name. You should use their name to specify their location, rather than the IP address. Internally, the name will be resolved to the IP address.
You can find the name in the service details in the web console.

How to use the API Sesame with Tomcat server into a Java dynamic web project?

I developed an Java application who request in SPARQL on Sesame repositories.
I use currently a Tomcat server what I run on console (with ./startup.sh).
I must now include my application into a web page and I choose J2EE.
But I have a problem : I can't run a Sesame connection and use JSP files, servlets,...together.
I have this error :
Etat HTTP 404 : The requested resource is not available
How to "join" us ? Is it a conflict because of the "8080" port ?
You have not provided enough information about how you have configured your Tomcat to allow a meaningful diagnosis.
But I can say with certainty that it is possible to run Sesame repositories and JSPs on the same Tomcat service ... if you configure them correctly. Indeed it is possible that you are already doing this, but you are using the wrong URL to access the resource.
How to "join" us ?
I suggest that you start by looking at the Tomcat documentation on how to configure the server, and how to build a basic webapp.
Is it a conflict because of the "8080" port ?
That is unlikely.

Categories

Resources