Cannot Access Google App Engine Instance Externally - node.js

I'm running a node JS app on Google Cloud Services using the cloud shell. I've deployed using gcloud app deploy, everything reports as a success. If I use gcloud app logs tail -s default I can see the logs, it says my app is listening on port 3000, that's the first debug message I see from my app.
When I invoke the endpoint without the port on the end, i.e.
https://myapp.appspot.com/myendpoint
I get an error,
"GET /myendpoint" 502
If I try with port 3000, i.e.
https://myapp.appspot.com:3000/myendpoint
The request just times out and I get no log messages from the shell.
I have port 3000 opened on the firewall, and my app.yaml is,
runtime: nodejs
env: flex
service: default
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
Update 1:
I've also tried adding a forwarding port to my app.yaml,
network:
forwarded_ports:
- 3000/tcp
And allowed port 3000 in the VPC Firewall, but this seems to make no difference.
Update 2:
I can SSH into the instance and access the endpoint using a wget http://127.0.0.1:3000/myendpoint command but still no external access.
Update 3:
I've also tried port 443 too, listening on IP 0.0.0.0. But it seems to bind to IPV6 ip address 0 and changes the port to 8443 (somehow). This is just insane...

I resolved the issue by binding my service to port 8080, and removing the "service" field from my app.yaml. the external calls are all routed to port 8080 by default.
External calls have no port specified.

Related

Running Logux on Google Cloud Run doesn't find the running port

While trying to get Logux running in Cloud Run, I get this error:
Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable.
Even though the server is running an the Dockerfile is exposing the correct port (which is mapped in Cloud run as well).
The Dockerfile is located here: https://github.com/knownasilya/battle-chess/blob/main/Dockerfile
Note that the server runs https and ws on port 31337.
As mentioned by the Cloud Run Troubleshooting docs, if we get the message:
Container failed to start. Failed to start and then listen on the port defined by the PORT environment variable.
And we know our code/container is working as expected, we should check that the port that that Cloud Run will be checking correlates with the one used in our app and like in this case, that the container listens on 0.0.0.0 (all the net interfaces)
As well this is mentioned in the Cloud Run Requirements doc:
The container must listen for requests on 0.0.0.0 on the port to which requests are sent. By default, requests are sent to 8080, but you can configure Cloud Run to send requests to the port of your choice. Cloud Run injects the PORT environment variable into the container. Inside Cloud Run container instances, the value of the PORT environment variable always reflects the port to which requests are sent. It defaults to 8080.

Access NodeJS server installed on Linux server

I created my App from this boilerplate
https://github.com/Bikranshu/express-react-boilerplate
Now I uploaded it to a live Linux server and Node server is running.
Screenshot of running server
But I am unable to access it through Browser with IP address of server.
http://ip_address:3000
After waiting long in browser it is showing timeout error.
Please guide me how can I access the node/react app from browser.
Server running at <ipaddress> is a local IP, are you in a different network than the server? If so, you should be typing https://<public ipaddress>:3000
UPDATE
Hosting services usually only forward port 80 (http) or 443 (https.) This means that your port 3000 is not allowed for public access. To fix your problem you need to change the listening port.
Check line 42 on
server/app.js change 'port' to "80" or check package.json and edit npm start to set port to 80

Have a Lando web server listen on localhost:8000

Long story, but due to previous configurations of 3rd party services, it'll be much easier if I can have Lando listen on port 8000 instead of the assigned docker port (e.g. it's different every time). I've tried doing overrides such as
overrides:
ports:
- '8000'
Is it possible to configure Lando so that my apache server listens on port 8000?
It is not an answer to your question, but if you use Lando proxy, you would not have a problem with changing appserver port and you can point your http request to the selected hostname.
Example of .lando.yml:
name: test
proxy:
appserver:
- test.localhost
- my.local-domain.test

Google App Engine two ports on same application

I want to run a node js application on Google App Engine but my application is currently running two protocols, on two different ports. One of them is the port 8080 (which is required to work on Google App Engine) and the other one is 1883, a mqtt server. Looking the documentation, I couldn't find anything to make this works, actually, the server starts without errors but of course I can't connect to the port 1883, only the http and https.
I need to know if this is possible at all and if is, how do I forward that port or proxy that?
My app.yaml:
runtime: nodejs
env: flex
service: comms-server
network:
name: default
subnetwork_name: default
forwarded_ports:
- 1883/tcp
Also, my VPC configuration is:
Try the following:
network:
forwarded_ports:
- 1883
instance_tag: comms-server
And:
gcloud compute firewall-rules create default-allow-comms-server \
--allow tcp:1883 \
--target-tags comms-server \
--description "Allow traffic on port 1883"

Dockerized Node on AWS Elastic Beanstalk. Error 502 BadGateway

I have a Node app (Isomorphic React app) dockerized and deployed to AWS Elastic Beanstalk. I have all the information below but if you want a tldr: How do you configure port forwarding between a host and a container in AWS Elastic Beanstalk i.e. 5000:3000?
I want my application to work like this (the numbers are ports):
End User --80--> EC2 Instance / Nginx --5000--> Container --3000--> Application
I used the Dockerfile to EXPOSE 5000. I know that it's just a suggestion but as far as I know Amazon uses it to expose ports in the docker container instead of a docker-compose.yml. The app runs on port 3000. Code in the node to run on port 3000:
process.env.PORT || 3000
When trying to access the site using port 80, I'm getting a 502 Bad Gateway error.
I SSHed into the EC2 instance hosting my docker container. The nginx config for elasticbeanstalk looks like this:
upstream docker {
server [CONTAINER_IP]:5000;
keepalive 256;
}
The IP is the correct IP of the container (I checked by using Docker Inspect). When I run: sudo docker ps -a
I get:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
REDACTED REDACTED "node server.js" 34 hours ago Up 34 hours 5000/tcp jolly_williams
If I run netstat on the EC2 host instance I see that port 80 is open:
tcp 0 0 0.0.0.0:80
When I look at the logs on the EC2 host instance I see this error multiple times for different resources:
request: "GET / HTTP/1.1", upstream: "http://[CONTAINER_IP]:5000/", host: [Beanstalk URL] connection refused
Now here is the kicker, it works when I run:
sudo curl [ContainerIP]:3000 (from the EC2 host intance)
-or-
sudo docker exec -ti [CONTAINER_NAME] curl http://localhost:3000
Anyone know why the node is running off 3000 and not 5000? What can I do?
Talked to AWS Support. They're saying that the docker port has to be the same port the application is listening on i.e. no port mapping

Resources