I would like to make web application based on Spring REST with SQL db and React frontend.
While it's OK for me, to deploy it locally, I don't really know, how to make it visible on public website. I thought of Azure, AWS, Google Cloud, but I cannot find any sufficient information.
Should I run frontend and backend on two independent Web apps? If so, how would I make them communicate?
Thanks for any replies!
If you are using AWS cloud, You can make it public using aws cloudfront which serves static content from s3. You just need to upload your react build on s3 and you can host via cloudfront.
For your spring rest service you can deploy your .war Or .jar on AWS Elastic beanstalk(EBS).
Your database should be on AWS RDS
Using those service you can ealsy host your website with react frontend, spring rest services and database handling
Front-end will make REST API calls to your backend to fetch/retrieve or to send data. This is usually the way frontend communicates with backend.
In order to make your applications accessible to the public over internet, you will need an external IP address.
Your backend and frontend applications may use the same IP but different port and access paths.
You might also need to have a domain name and DNS setup against your ip.
Backend will be deployed independently of frontend and you can have both of them running on same machine.
You can start your Backend as a Spring Boot Application on any standard port available. [default is 8080].
Same can be looked up by your React Frontend using process.env.API_URL.
Below article from DZone is a rich source of information.
https://dzone.com/articles/integrating-spring-boot-and-react-with-spring-secu-1
Also to achieve the same, you can try a simple combination of AWS EC2 & RDS combination to start with and enhance it as per requirement.
Related
I have to make an application in tomcat which core responsibility is to redirect all request coming from browser application to API server. It works like proxy server between browser application and API application. Have to write it on tomcat. How can i achieve this, do i have write a REST API application on tomcat too?
Project Description
Requirement is like we have two application one is developed on React, its a web-portal and the other one is on spring-boot as a backend application (json apis).
spring-boot application is going to be deployed on secure zone and web-portal is in DMZ. web-portal in on internet, backend application is on intranet. As web-portal is a CSR application so the api's calls from web-portal contains backend application IP/URI but it cannot be accessible from internet.
So i am planning to write an application on DMZ zone and it will be deployed on apache tomcat, so like when request comes at tomcat it redirect it to backend application server which is on intranet with all headers/payload and redirect response from backend server to web-portal.
You want to set up a reverse proxy which is a standard pattern. Take a look at the answers at Reverse Proxy Java or just search the web for "reverse proxy java".
If you are not bound to implement it in java take a look at Nginx which we use in many projects to transfer the request from the web app to the REST backend.
I have restful spring web service running on tomcat server and have mysql database on backend. I deployed war file of my service using aws elastic beanstalk free account yet but I am unable to setup mysql database. Can anyone guide me on this matter ? Secondly, our application has android side code which will call my REST API so is there any other way to do this instead of setting up amazon web services for testing purposes ?
You are going the right way; Android should call REST APIs. These APIs can be implemented in following ways:
As you suggested; use spring on tomcat to expose such apis.
Use API Gateway exposed by AWS. This api gateway can even call lambda expressions in backend which can be written in Java/Python etc.
I will suggest you to go ahead with 1 as u are already aware of spring/tomcat etc. and MOST companies use this only.
For MySQL database you have following options:
Install MySQL on your local EC2 server ( where you have tomcat running ); or on another EC2 server.
You can use MySQL as a service which is RDS. It is expensive but easy to configure.
I am shifting my applications to cloud foundry. I have pushed my front end as an html app and my backend REST services provider as a Java app. Now, I want to make HTTP calls to my backend java app from my html app. I know I can hardcode java app's url, but what is the best practice here? I can't seem to find anything after considerable world wide web search.
Best practice is to use a dedicated directory service like Eureka to discover your backend Java app. Chris Richardson provides a good overview here:
http://microservices.io/patterns/client-side-discovery.html
Spring Boot/Spring Cloud make it extremely easy to a Eureka server up and running, and for your Java app to register with the server:
http://cloud.spring.io/spring-cloud-netflix/
For your HTML app, you will want to use a Javascript client library to access your directory service, like this one:
https://www.npmjs.com/package/eureka-js-client
I have built a mobile application that needs to connect to my SpringBoot-WebApp which in turn has a MongoDB and some other things in the background.
I want to deploy this WebApp at Amazon AWS, but I am overwhelmed by all the possibilities. So far, I have just created it as a .jar, and ran it that way, and it worked fine at my other server.
Now, for traffic reasons and such, we want to move it to AWS. I have found out, that I need to create a .war instead of a .jar, which is not a problem. I then learned to upload this .war to Elastic Beanstalk. However, my application needs to connect to a MongoDB. I have logged on to AWS via SSH and installed MongoDB there and created the database, but it does not seem like this is the right way to do it.
It'd greatly appreciate if anyone could give me a hint on how to do this as I am very confused.
Thanks and best regards!
It isn't clear if you are doing this, but don't run MongoDB on Elastic Beanstalk. The Elastic Beanstalk server you have it installed on may be automatically deleted by AWS. In general you do not want to manually install anything on Elastic Beanstalk as it is a managed environment where servers may be automatically created or deleted based on server load.
Amazon doesn't provide a MongoDB service directly, so you either need to install and manage MongoDB on an EC2 instance (or fleet of instances) yourself, or use a third party MongoDB service that runs on AWS. You could use something like MongoLab which provides a MongoDB service that runs on AWS. This allows your network traffic between your web servers and database servers to stay within the AWS network, which you will want for both performance and security reasons.
If you use MongoLab just make sure you choose to create your database in the same AWS region that you are deploying your application to. Also, I wouldn't recommend their free sandbox databases for any sort of critical production application.
If you decide to install and manage MongoDB on AWS yourself, here is some documentation from Amazon, and some from MongoDB.
I'm planning to build a two-tier application, with a back-end (java, possibly spring MVC) which delivers JSON up to a front-end (PHP, Drupal7). I only want the front-end application exposed to the outside world and in a traditional environment I would probably stick the back-end on some ports inside the firewall (assuming both parts run within the FW).
Is this possible to do in the Google App Engine environment?
It's not possible to run GAE inside your firewall. It runs on Google's servers.
You can do basic things like blocking IPs but its not really necessary. Since your 'front end' has the php backend you can call from there your appengine with a secret parameter (as in "myapp.appspot.com?key=sE34sdJSjUy" ) Its very simple security and since no one can see that url (in your php backend), its as good as any other authentication method.