Express backend & React frontend under the same domain - amazon-elastic-beanstalk

I have a backend in Express.js deployed on Elastic Beanstalk and a frontend built with React.js deployed on Amplify and I would like to make HTTP (using axios) requests from the frontend to the backend via relative paths.
I'm quite new to AWS but I figured I could use Cloudfront to set the backend as a behaviour?
I have a domain (mydomain.com) for the frontend where the DNS are pointing to Amplify cloudfront (which I think I can't access...) and Elastic Beanstalk has its own aws domain (http://app-name.region.elasticbeanstalk.com/).
The frontend seems to be working fine as if I go to mydomain.com I can see it. Also the backend seems to be working as if I go to http://app-name.region.elasticbeanstalk.com/api/user it would return the expected json data.
The idea would be though that mydomain.com serves my React application which internally would make calls to, for example, mydomain.com/api/user where my express backend would serve the user.
I got lost in the docs and on the internet didn't really find anything.
Is using Cloudfront the right approach? If so, how do I connect Amplify and Elastic Beanstalk?
Any suggestion would be very appreciated!

Related

How to redirect HTTP to HTTPS from Classic Load Balancer in AWS

We have a web application developed in Asp.NET MVC Core 3.1. Deployed it using Elastic Beanstalk.
Configured Classic load balancer for this with AWS issued certificate listener. Our classic load balancer's listeners configured as below.
Using this setting, its not redirecting from Http to Https. However if we try to access website individually with Https and Http its working fine.
We don't want to change Load Balancer Type from Classic to Application as the environment is already setup in Route S3 too.
Can you please help if anything missing in this?

nomad consul traefik https

I have a go app that i need to run multiple instances under separate subdomains, i have a working nomad consul setup and got the go app to run and is accessible via a fixed ip address and dedicated port. But i am stuck on how to make it work with the unique subdomains and working https.
So what i'm looking for is like
app1 runs on https://app1.example.com
app2 runs on https://app2.example.com
I tried to use traefic (got it running as a job), DNSmasq but i havent got the above to work.
Any help would be much appriciated.
Traefik supports integrating with Consul through its Consul Catalog provider. See https://learn.hashicorp.com/tutorials/nomad/load-balancing-traefik for an example of how to configure this when running Traefik on Nomad.
The example in that tutorial configures the tag traefik.http.routers.http.rule=Path('/myapp') on the service so that requests for /myapp are routed to the backend service instance. In your case, you'll need to modify this to match on the HTTP Host header so that you can route subdomains to different services. For example:
tags = [
"traefik.enable=true",
"traefik.http.routers.http.rule=Host(`app1.example.com`)",
]
See https://doc.traefik.io/traefik/routing/routers/#rule for a full list of supported rules.

Node JS Deploying API to client without any Front End

If i created api in nodejs like login,registration,delete,add,update user like system and i want to give it to my client how can i deploy it??
Like we run our API's on POstman so how client will use it! I don't want to add any front End to it.
You have a few options... you can go for heroku or a virtual private server. For vps you have options like aws ec2, google cloud platform etc. You can host your app in a vps with a static ip. You can use pm2 to host the app. Https is better. Use an nginx reverse proxy for security. Proffesional api servers do the above...

json rest api, locally hosted, lan accessible

For some time now I try to figure it out how to create a json rest api and a database, host it locally and make it accessible in lan. I need this for an android app, exactly to parse data from database to app.
I created the json rest and database usimg XAMP but i didn't figure it out how to make them accessible from lan.
After that somebody recomanded me IIS and since then I did'n figure it out.
Some sugestions?
For the web api application, host in the IIS server in some other system. In the mobile application development environment is in same LAN network, then call the api using that web api system ipaddress instead of the localhost.

Haproxy issue with Openshift

I am running a multisite instance of Locomotive CMS on a scalable Openshift cartridge.
The issue I am having is that haproxy sends GET requests to the root of each Apache instance, returning an erroneous 404, because no host is specified.
Locomotive works fine, but needs a host to each request, so it will serve the appropriate website.
How can I workaround this problem?
You can try sshing into your gear and modifying the ~/haproxy/haproxy.cfg to check a different url instead of / to make sure that your application is up and running.