Redirect http request(via browser) to local server - node.js

I have nodejs http server running on port 9000.
Now for some hostname how do i redirect normal request to this port.
Example : if I hit www.specficDomain.com in browser, it should go to www.specficDomain.com:9000.
Thanks,
Shantanu

Related

Ngrok - HTTP 400 with virtualhost

I have created a url in ngrok integrated in my webhook of stripe.
But when I call that url, I receive a HTTP 400.
I have a domain name attached to my localhost url: abc.com:port and i have registered that address in my host-file. I executed ngrok like this: ngrok http port which gives me localhost:port.
What might be the issue for it?
See the documentation on how you can "ask ngrok to rewrite the Host header of all tunneled requests to match what your web server expects."
"For example, to route to your local site myapp.dev, you would run:
ngrok http -host-header=myapp.dev 80"

Redirect all request internally to 3000 port apache2

I have a web application hosted on apache server. When I hit https://example.com then it points to the server but my application is running on 3000 port. So I want all the users to hit example.com (443 port) and internally it redirects all the request to 3000 port and make my application running.
You want to create a reverse proxy with Apache. These tutorial may help you:
https://linuxtogether.org/configuring-reverse-proxy-for-node-using-apache-mod-proxy/
http://garrows.com/blog/running-node-js-and-apache-together-using-mod_proxy/

Application working on http but not on https

Background: I have two backend instances running haproxy, apache, nodejs on ports 4000 and 8007 for haproxy, 80 for httpd, 3000 3007 3012 running node. I have a staging site which is running on this instance. I have signed certificate installed at ELB level and ELB listening on https 443 port to backend http 80 port.
Issue: When I tried to login to the stating url with http then the backend is working fine on port 80 and 3000, network flow logs also returning status code as Ok for request to http://stating _url:3000. But when I tried to access site on https then I am getting status as "blocked:mixed-content" for https://stating _url:3000 request. Please refer to below screenshots
Below is output for http which is working as expected
Below is the output for https which is not working as expected
I tried different protocols for listeners at ELB level. I dont understand why ELB on port 80 sends request to port 80 on backend server and all works fine but same ELB on port 443 sends request to same port 80 on backend server but fails to establish connection with 3000.

Why are HTTP curl/Postman requests to a HTTPS server working? (Node, AWS)

I've set up a HTTPS Node server on AWS EC2 which runs on port 4443 and set up Nginx to redirect requests(port 443).
https.createServer(options, app).listen(4443, function(){
console.log("https server started at port 4443");
});
The HTTPS server is working fine, I get a secure connection on browsers and
curl https://mydomain/apiroute works
Now, when I do
curl http://mydomain/apiroute the requests still work. The same goes for Postman.
I know that I can redirect all HTTP traffic to HTTPS using something like 301 redirects but my question is, why does the server respond to HTTP API calls inspite of there being no "HTTP" server?
Additionally, I use a letsencrypt generated certificate.

How do I use HTTPS port on clould9 ide?

I am just running some tests on c9.io - but I am stuck on how to get the HTTPS server to run.
I am using the port given in process.env.PORT which links up to the browser in c9, but there doesn't seem to an HTTPS port. In a local environment I use port 3001 for HTTPS.
The Cloud9 workspaces don't support custom SSL certificates yet so you won't be able to start an HTTPS server from there, but your http server running on 0.0.0.0:8080 will be accessible via both HTTP and HTTPS.

Resources