Jelastic giving 502 on a nodejs application - node.js

I'm running a nuxt (running on node engine) website on a simple jelastic environment made of a load-balancer (nginx) and 2 nodejs container. I'm using pm2 as a process manager.
Nuxt is listening to its own ip and port 8080. (as stated here).
When I try to access my website I get a 502 code.
The strange thing is that it used to work, I've tried reverting my project to older working version and nothing works.
If i do a curl to the ip address and port used by nuxt I get back my correct HTML, which indicates to me that it's not an issue with Nuxt anyway.
Jelastic states that it redirects traffic from port 8080 to port 80. I don't know what to and am a bit lost.
What should I check ? Any help is appreciated.

As for the described situation - we've checked the nuxt application deployment on the Jelastic NodeJS node and all seems to work fine.
Please check the next possible issues:
Check if the hostname in the application config is not 'localhost' but '0.0.0.0' (check if it was not erased during the downgrade), details via the link
Check if the JELASTIC_EXPOSE variable is not set to '0', 'DISABLED' or 'FALSE' - in such a case the auto-redirect will not work (more details on auto-redirect here)
Try to set the 'JELASTIC_EXPOSE' variable to the exact value 8080 (or another port that is actually listening by your application)

Related

Express server unreachable from browser when running in WSL2

So, I have been trying to start a basic express server from inside WSL2 on port 3000. Every time I go to the browser, it says that "localhost:3000" is unreachable. I'm not really sure where the problem is. I have been able to start and access react applications that are running on port 3000 in WSL2 without a problem. Additionally, I have been able to start Flask servers from other ports on my machine from within WSL2 without a problem. The issue somehow seems isolated to Express JS servers, which doesn't make a whole lot of sense to me.
I have confirmed that the app is exposed on all interfaces, so localhost should be reachable.
When starting the application, I have been monitoring it with netstat -ltp. The node process does show up in the output, which indicates that the port is listening.
Are there any weird WSL2 configuration steps that I missed. The strange part is that other applications that don't use Express JS, applications seem to be running perfectly fine on all ports.
I also already have all local ports accessible through the Windows Firewall and have made the ports accessible on the Windows side via this command: netsh interface portproxy add v4tov4 listenport=3000 listenaddress=0.0.0.0 connectport=3000 connectaddress=127.0.0.x
I have also been testing this using npx express-generator your-project-name --no-view to create a standard Express JS template.
Update:
The server is reachable from the IP address on my network, but unreachable from localhost.

How to remove port from url for node application using nginx

My react and angular application (UI have two parts) are running using
node/express application on port 3000. On server.js (node-express entry point) I dynamically
handle which UI to render (react or angular at a time) on a browser using
express-static feature.
Earlier my application is running on - https://mywebsite.com:3000/ but
as per requirement it should be changed to - https://mywebsite.com which we
handled using "nginx proxy" with DevOps person but now encountered
another issue actually now UI is accessible by using both URL that is
https://mywebsite.com:3000/ and https://mywebsite.com. I want it should be
accessible by using https://mywebsite.com/ only without port.
My server's API's (https://mywebsite.com:3000/api/v1 ) is accessible from three places: -
1) iOS app
2) Admin app (running differently)
3) and UI ( React.js + Angular.js) (https://mywebsite.com)
Note- Is there any way to handle this either through the deployment process or setting at node/express server level. We found one solution that is to create a separate node server for the UI part but as per cost-cutting, we ignored this approach that is creating another server for UI.
Suppose my domain name is https://api.aegisapi.com:3000, first, you can check in your inbound, means HTTPS is present or not if not present then add HTTPS for 443,
then you can run https://api.aegisapi.com. It works.
When you run your node server like this
it listens on all interfaces i.e. 0.0.0.0 which is accessible from outside.
You should your listen to
from
app.listen(3000)
to
app.listen(3000, '127.0.0.1');
Also, you should also block this port with IPTables as well.
if using AWS EC2 instance then open inbound port 3000 and open public facing port e.g. 80 or 443 to get request from users, then as you are using nginx as reverse proxy use that to forward request to port 3000.

Apps running on different ports are not reachable from client side. (CentOS)

EDIT:
Issue resolved. I had to open the ports via the Plesk firewall.
I moved my node-application from my local Debian-VM to a CentOS-Server, where it also will be running in production one day.
There is the react-frontend part. Which is for development running through the react-scripts to start on port 3000 via npm start.
Then there is the backend which is just an api for fetching data and stuff, built with express.
Problem: Although starting these up throws no error at all, I can't access them through the browser or postman.
On my local VM it was just localhost + :port, but now I have an domain and I think there is the error that I don't see nor understand.
Hope someone can shed some light here. :)

Node.JS SteamBot on openshift

i´m trying to host my node.js steambot on openshift, i haven´t used it before, so basicly what i´m trying is to Commit a basic "in my eyes, not a server" to their nodejs "hosting".
so, when i commit the files and such, everytime the app starts, it tells me that "port 8080 is not available" and so it can´t start.
idk what is blocking the port so.
what could be the issue ?
regards
The openshift environment is very restrictively firewalled for security reasons. As such you cannot open just any port for your server. The only port you're allowed to open is:
process.env.OPENSHIFT_NODEJS_PORT
If you do testing on your own machine before uploading to openshift, it is useful to check if this environment variable exist or use your own port (like 8080). So you'd typically use do:
var port = process.env.OPENSHIFT_NODEJS_PORT || 8080;
For the outside, you access your openshift server using the URL they gave you at port 80.
OpenShift will routinely check your application to see if it is working correctly. The expectation is that all apps are "web apps", so if you are not listening on the correct port, your app may get rebooted, suspended, or may fail to start correctly.
For your bot to appear to be in good health, you'll need to bind to (process.env.OPENSHIFT_NODEJS_PORT ,process.env.OPENSHIFT_NODEJS_IP), as described in "Run Your Nodejs projects on OpenShift in Two Simple Steps".
Returning a simple HTTP 200 on "/" should be enough to convince OpenShift that your bot (web app) is in good health.

setting up a MEAN app in production

I am a frontend developer and having issues setting up my MEAN app in production server. I am confused about the role of apache ? if any.
right now I don't have a domain name, just an IP address for a CentOS 6 VPS.
I stopped apache and am using express only, I deployed the app code and ran the grunt task in production environment and the app is listening on port 3000 .. but when I visit the site at
http://104.238.103.223:3000/ I get a "page not available" error
I am confused at how to specify a "DocumentRoot" without apache ? how do I tell DNS where to find my app ? I may be looking at the problem wrong since I am not well aware of the backend side of things.
You should reverse proxy to port 80 (or 443 for https) to access your application with your domain name. You can use apache, nginx or haproxy etc.
Also check your firewall if port 3000 is allowed.
Check out this page; http://blog.podrezo.com/making-node-js-work-with-apache/

Resources