Nodejs and Wordpress both port 80 virtualhost configuration on Mac - node.js

I am currently running my node.js web app on port 80 on my Mac with domain www.aaa.com,
But now I want to add a Wordpress(Apache) on 80 on this Mac machine too with domain www.bbb.com,
how do I configure the virtualhost? I tried many researches on the internet, but no luck , can anyone tell me how? Thanks!

If you can have multiple public IP addresses, you just need to:
map each of the domains to a different IP address
have node.js and Apache listen on one of the IP addresses each
If not (you only have a single IP address), you'll need to have one of the two servers take port 80 and forward/proxy the data to the other (listening on a separate port) for its requests. Or, alternatively, use a reverse proxy (such as pound) to do this job (you then have the reverse proxy on port 80, and both node.js and Apache on other ports).

Related

Make a subdomain to point on a specific port

I already checked some topic about it but didn't find any solutions (if it's possible). I have a domain that points on my server on the port 80, but, I have another important webservice running on the port 8080.
I want to know if it's possible to create a subdomain like (admin.example.com) which points on port 8080.
Thanks
The simple answer is no. The server name is resolved by a DNS query to a single IP, to which port the connection is made is between the application and the server. For HTTP the conventional default port is 80 and HTTPS 443, if you need to use another port, you need to include it in your URL.
SRV entries in a DNS record can be used so resolve a hostname to a specific port, but this works reliably only for a handful of protocols that mandate its use.
Currently the preferable way is to set up your server with a reverse proxy to direct traffic by a specific server name (your subdomain, carried in the request headers) to your admin service. This is quite easily done using e.g. nginx.

Docker: Multiple container on port 80 without NGinx

I want to run multiple web server on the same VM. Each web server is dockerized.
Is it possible to run multiple dockerized web servers on port 80, with different domains, using docker functionalities?
I found many solution based on NGinx proxy like here , but I don't find any user defined network usage that solves this problem.
Is there any solution to this problem without running a reverse proxy?
No.
There is only one "real" port 80 on the host server (for each network address), so you need something that listens there and forwards to the different backend servers.
This is not a docker-specific problem. You cannot run multiple (non-Docker) web servers (one for each domain) on a single port either.
That something does not have to be nginx.
As far as I am aware, no it can not work to have multiple containers listening on port 80 or the same port in general.
You could open up different ports on your VM and have the applications listening to each one of those ports specifically.
For instance you could have your first application listen to port 80. Then your second one on port 81, etc.
First of all it is possible to run multiple domains on the same port, but the requirement is that:
you host sites on the same web server (Apache HTTPD or Nginx)
you are using virtual hosts
The one server can be containerized, if needed.
Here is the example of running two domains on exactly one Nginx web server.
So depending on your requirements, that can be solution.

Does Kestrel support urls/hostnames, or it can only listen to a port?

I'm trying to start ASP.NET 5 web application so that it could be accessible via public internet address, like "http://hostname.dom".
I don't want it to be acessible via "http://www.hostname.dom", "http://test.hostname.dom", etc. And I have DNS records configured to point server's ip address by "*.hostname.dom" and "hostname.dom" names.
So I start Kestrel with the parameter:
server.urls=http://hostname.dom
I expect it to ignore any address that is not "http://hostname.dom", but application is available by every "http://justanything.hostname.dom" address and even just by IP address. So it is listening for all requests to 80 port rather than requests to a specific hostname.
For example, when configuring IIS site bindings, you can specify binding like "hostname.dom" and it will ignore any other possible prefixes until you specify them explicitly.
Does Kestrel support urls/hostnames, or it can only listen to a port?
Well yes, Kestrel doesn't support hostname listening. Only ip:port binding. To make it possible, you, my friend, either must use another hosting solution (like WebListener, if running on Windows) or configure forwarding with a webserver: http://druss.co/2015/06/asp-net-5-kestrel-nginx-web-server-on-linux/

deploying a node.js on a new domain

I have a server that runs different websites on different ports. All of them (but one) are Apache servers and thanks to webmin, I managed to have, for instance, example.com point to 123.123.123.123:80 and example.fr to 123.123.123.123:8000, somehow automatically
I am now running a nodejs server on the same machine, so the 80, 8000, and many other ports are already taken. My nodejs listens on 8008. I have another domain name, say example.org, and I want it to point to my nodejs website, but I simply don't know how to do that! I have updated the DNS and everything is pointing to 123.123.123.123 (my server's IP). I want to avoid using an ugly example.org:8008/ for everything on this node server. How can I make it point implicitly to the 8008 port?? I must add that I cannot afford to take down the apache servers ;)
DNS only provides name to ip address mapping. It cannot handle ports. What you can do instead is to set up a proxy server listening on port 80. The proxy server can then return data based on the host header.
Your best option is to just redirect the request from Apache. Otherwise you can use a reverse proxy like Nginx. Also, you can write a lightweight proxy in node... check out this page

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