Apollo with AWS Cloudfront. Not getting playground query client - amazon-cloudfront

I am running Apollo server in the ec2 instance, due to update the https URL I connect my ec2 server with Cloudfront so that I can get the https url. Now when I open the URL I am not getting a playground query client.
Ec2 server is running 4000 port, and also Cloudfront HTTP port opens 4000.
Here is my Cloudfront url look like https://text+cloudfront.net/graphql I am not getting any query client. I just getting an auth error that is returned from the server.
But If I request ec2 URL directly it works http://ec2-3-3939-93-217.us-east-2.compute.amazonaws.com:4000/graphql

Related

How to make an HTTP request from a remote web client hosted by an npm server to a private port of a backend server running behind the Linux Firewall

There is a front-end npm server hosted on a public port 80 in my production environment. I can launch a remote web browser client of this front-end server using its public hostname, e.g., http://hostname:80, and successfully load the webpage.
The Javascript in this app makes HTTP GET/POST requests to a back-end server to fetch some data on the URL: http://hostname:5000. This back-end server is running on the same production environment but on a private port, e.g., 5000, i.e., this port will not be visible outside the firewall.
As I understand it, this HTTP request is essentially made from the remote web browser client sitting outside the firewall. Due to the Firewall (UFW) policy, any request made from this client on private port 5000 gets blocked.
I do not want to allow the private port 5000 in the UFW, and I do not want to run the back-end server on a public port of the production server.
What are the solutions for this?
I have heard about the Nginx proxy server which redirects client connections on a public port (80) to a Node application running on a different port (3000).
Reference: https://blog.logrocket.com/how-to-run-a-node-js-server-with-nginx/
However, I am not certain if the Nginx server would be able to handle the client requests beyond the UFW rules.
The majority of request information is sent to the backend from the proxy.
A request sent through the nginx proxy will act like a request directly to the backend.
Some fields may not be passed, for example:
From nginx.org:
By default, nginx does not pass the header fields “Date”, “Server”, “X-Pad”, and “X-Accel-...” from the response of a proxied server to a client. The proxy_hide_header directive sets additional fields that will not be passed

How to set HTTPS redirection to HTTP 8000 port in an ec2 AWS?

I have an Angular app working fine with a custom domain on AWS Amplify, well, this app is connected with a NodeJS backend, located on an ec2 instance.
I am using HTTPS for the Angular app, and I also need to use HTTPS to the ec2 instance.
I have configured a Load Balancer to redirect HTTPS to HTTP port 8000, and added the Load Balancer to Route53 to use a custom domain, and here is when my problem come in.
When I do a http request it works fine, but when I do a https request this error throw in.
enter image description here

How do I fix the Error when setup AWS Application Load Balancer For Angular+NodeJS Web Application

I set up an Application Load Balancer(AWS) for my website. In my website, I have angular as my frontend, and I have NodeJs and Neptune DB as my backend.
Browser(Local Machine) -> ALB -> EC2 Instance(Web).
I have an url for my web(https://example.com), so when I made a request to https://example.com in my local machine browser, Angular will do a api call using httpclient.get() to fetch data from nodejs at https://example.com/api/ticket.
So my question is when Angular fetch data from NodeJS, will the api call bypass the ALB, what is the host then? Or NodeJs will recognize the request is from the local?
I assume you are using an ALB with Host based routing. In this case you can have a 443 rule for example.com forwarding requests to the EC2 instance. Then in the Nodejs application you can have that api called using the same url.
This means that the request will be routed through the ALB which is also the best practise to do the same.

socket.io on AWS EC2 Instance

I have an express node server running that is a backend for a REST API and a Websockets (for chatting feature) while my client is React.js
When I deploy my server to an AWS EC2 instance with security groups set up, I am able to make http api calls, but my socket.io connection doesn't work. I have tested the server locally on my localhost, which works.
I think this does something with the proxy in the package.json because testing locally when I change the proxy to my EC2 instance public ip while keeping my socket.io connection connected to my localhost it does not work.
I am not getting any "connection refused" errors.
So my question is how does the react.js proxy effect the socket.io connection?

how to remove port number from url in aws while connecting to the API server

I am able to connect to my Nodejs API server through aws by entering url such as ip + :3000. Now I do not want to show port no 3000 after url. is there any way to hide this or this will be there compulsory?
You can't do this on the client side. You need to do one of:
Have your nodejs server running on port 80/443
Run a webserver (apache,nginx) on your nodejs server as a reverse proxy
Use a load balancer.

Resources