Mapping a Subdomain to a NodeJS web server running in a docker container with a specific port? - node.js

I have a server running Pterodactyl panel which uses Docker. I'm using a Nodemon js egg to run a Node JS webserver I developed. The server uses 5500 as the port. The ufw firewall is set up correctly.
An issue I am having is accessing the webserver from a subdomain. I can access the webserver using [server ip]:5500 perfectly fine. I set up an A record pointing the subdomain to the server IP but it brings me to the Pterodactyl panel instead of the webserver.
I have edited the Nginx (pterodactyl.conf) config to point it to the correct port but it doesn't seem to work still.
What would I need to do to make it work?
Screenshot of Nginx Config

It's because the new website is not currently listening to that port. It also happened to me, all sub domains were pointing to pterodactyl panel, it was because the new website was not listening to new port, than you need to restart nginx so it shows correctly

Related

How do I deploy a Next.js app to an addon domain on cPanel, which listens to port 3000 without affecting my other domains?

I have a website running on my main domain added in cPanel listening to the main "80" port and can be opened without adding the port to the URL. for example: "http://mywebsite.com".
Now I want to add another website on a new addon domain. But this website is a Next.js app running on port 3000.
I used SSH to successfully build and start the next.js app.
The next.js app opens perfectly on the newly added addon domain with the port 3000. For example "http://new-website.com:3000"
- If I change the port from 3000 to 80 when starting the next.js app, I can open it without adding the port, but the problem is, that my other domain will now also open the next.js app.
My server Information:
Virtual instance running on google cloud.
CentOS 7
Apache Web server (I can turn off Apache and run NGINX if needed)
cPanel installed
I can of course just create another virtual instance and add my new website there but I don't want to pay double when my current instance is capable of running multiple websites on different domains.
Everything is working perfectly with my both websites and the only problem is I cannot have my both websites work currently without having to add port number to my next.js app.
How do I open my new next.js app without adding the port in a way that my other static website won't be affected and show it's content like before?
Tried:
I used NGINX reverse proxy, but the same thing happens.
Changing next.js port from 3000 to 80
Exporting the next.js app and uploading it as static using "npx next export" but website not working as expected.
Turns out it is possible to do this with Nginx reverse proxy and setting different ports and assigning them to different domains!
Got the answer from this Stackoverflow question:
Port numbers not hiding in nginx reverse proxy (next js server)
The link to the answer
In my case I changed server name from subdomain to my other website and removed the location since my other website is static and does not need port.
server {
listen 80;
listen [::]:80;
server_name my-website-2.com;
root "Website_directory";
}

Deploy Create-React-App on a remote Windows Server

I am an inexperienced intern working with a remote Windows Server and React. The Windows Server is running in the company network. I have created a dynamic React website with a NodeJs backend and React Router. I have only ran it on the localhost development server. I want to try to deploy it on the remote Windows Server and give it a custom domain name (Something which can be accessed like servername/myreactapp/).
So far, I have had no success trying to make it work with IIS, even with a web.config file (I get 404 and 500 errors). I am currently making it work by actually running the development server and the nodejs server in the Windows Server, and I access it through the server IP at port 3000.
An improvement would be to be able to access the port through the server name (like servername:3000, instead of the server_ip:3000), but ideally I want to be able to access it like servername/myreactapp/.
Any help would be appreciated. Thank you very much.
The simple solution would be to run your app on port 80 then you will not have to specify the port number.
The best solution would be to set up Nginx on the server and proxy_pass / route to port 3000.
If its running on localhost, which would be port 80, the url would be like http://your_server_name:80, and would be accessible by anyone on the same network, as long as your authentication allows it.

IIS Apache and Node.JS HTTP all on the same server

I have one windows server already running sharepoint on 80/443 and the site works correctly.
We're trying to add more functionality by installing NodeJS and Apache
I've set apache to listen on 8080 and the default website comes up.
Node is running on 3000 and I can access the explorer that way as well.
My questions come from this. The server has a complete certificate chain installed on it and https://:8080 comes up correctly, but I can't get the node stuff to work on https: Secondly it appears while I have proxy pass set up correctly within my httpd.conf, either something is wrong within that as if I goto the https://:8080 /api/and anything beyond that, I get 503 errors and the page can't be displayed.
I'm unsure what I'm doing incorrectly here as from reading the documentation on proxy module, it seems that everything is setup and configured correctly.
Netstat shows listening on 3000 and 8080 and 80/443 for my SharePoint farm.
I had to configure the ssl settings for the proxypass to use the IP address of the local machine. After doing that I was able to connect correctly.
This allowed for connecting on :3000 via telnet to the localmachine and allowed for explorer to be viewed with https://:8080 the correct way enforcing our certificates.

AWS redirect URL with AngularJS running in Node.js server

I´m trying to config a website hosted in AWS EC2 instance. But Im a bit mixed!!
I have an AngularJS application running in a Node.js server listening on port 1234. This site is deployed correctly, so when I get the url in a browser ec2-instance-public-dns:1234/app/index.html I see my site perfectly.
In the other hand, I registered a domain name in GoDaddy. I set up a Route 53 and the DNS names in GoDaddy.
I see, I also have a load balancer listening in port 80, that is redirecting to port 1234.
What I need is to link my domain with my site in the path ec2-instance-public-dns:1234/app/index.html
All this stuff is not working. How can I achieve this?
Is there is reason why you don't have Node listen to 80 or 8080 ?
Does the DNS redirection work ? -> Can you access your site with www.yourdomainname.com:1234 ?
-> If no, then check your dns config, you should not have to deal with port routing at that level.
Are you using Linux as your EC2 instance ? If yes, reroute port 80 toward port 1234 as explained here (http://www.cyberciti.biz/faq/linux-port-redirection-with-iptables/).
That how I do it, hope that helps.

How do IP addresses work on a VPS? Routing a domain name to Node.JS

This is an absolute newb question. But I'm buying my first VPS for the reason that I want to install and start creating applications in Node.JS.
I can't visualise in my mind how the server works and where all of the applications such as Apache, Node.JS and PHP sit. I'm so used to a GUI.
I want www.mydomain.com to point to node.JS on my server, let's say Node is listening to port 8080. Now I know that HTTP defaults to port 80 of the IP address, so I can't use that. How do I set the domain up to resolve at www.mydomain.com:8080 - I read this wasn't possible...
My brain is melting.
Thanks :)
You just point the domain to your ip address as you normally do. The issue you will have it that HTTP default to port 80, so either you manually add the port at the end of the host to get to the page or you setup Apache to proxy specific urls to 8080, which gets some of your Node stuff appearing to work under 80.
If you aren't using Apache for anything you can also have your Node app bind to port 80. You will probably need to setup authbind or something to give your node app permission to bind to port < 1024.

Resources