Node hosting application on my machine

So, I have a node application through which I can access through localhost: someportnumber. How to publish this application publicly (i.e. for the rest of interwebz, and not just for my local network), using only my machine, and not some hosting service. A machine is a macbook pro program that does not matter.

Note. This is purely for understanding, I do not want to constantly place the webapp toy on my laptop.

Here's my confusion - my node.js application is a WEBSITE, why do I need another server (i.e. the one provided by heroku, aws, etc.) to host my application? I feel like I'm missing something ...

+5
source share
4 answers

Assuming this is a home network, you probably have some sort of router / firewall that connects your home network to the Internet. By default, the router blocks all incoming network connections (for security reasons).

If you want, you can configure a so-called port forwarding rule in which you tell the router that you want incoming connections on port 80 (which is the default HTTP port from the browser) to be routed directly to your macbook pro on your home network . You usually do this by discovering the IP address of your macbook pro when it is on your home network, and you set up a port forwarding rule for that IP address. A port forwarding rule is usually configured through some kind of web admin interface that you can use in a web browser. You will need to see the manual for your specific router to find out how best to connect to it and configure it.

If you have not set a static IP address for your macbook pro, its IP address will be dynamically assigned by the router. It will probably remain unchanged for some time, but may change over time.

Once you do this, you need to open the IP address of your home web connection. This will probably also be dynamically assigned, but should also remain unchanged for a while. If you know this IP address, then the browser on the firewalls can connect to your web server by going to the URL http://xxx.yyy.zzz , where xxx.yyy.zzz is the IP address of your home network, as you can see from firewalls.

If you want to be able to connect to it with a common domain name, for example http://mysampledomain.com , that is, some dynamic DNS services for which you can pay for it, the domain will be configured to your dynamic IP address, although this is not recommended for prolonged use. In addition, it is likely that this contradicts your ISP rules, it is not a very scalable or reliable solution. Switching to a hosting provider will make more sense in the long run.

Here's my confusion - my node.js application is a WEBSITE, why do I need another server (i.e. the one provided by heroku, aws, etc.) to host my application? I feel like I'm missing something ...

You do not need another web server. If you want to find a hosting provider, you would use a hosting provider that would host node.js servers well. With these types of providers, there probably won't be another web server — your node.js server will be the only one. They may have proxies or load balancers that they use to work with multiple tenants, but you should not generally know about others, except that you follow the correct installation instructions to properly start your node server. js in their environment.

+8
source

You do not need a server to host the application - you need a server to access via the Internet. There are many ways to do this.

To access your web server application, I need to know the IP address of your computer. Let's say you can give me your public IP address (find it in What Is My Ip , specify the address I, and let me know which port to connect to.

Eg. The stackoverflow has an IP address of 104.16.34.249 , but you can only have an IPv6 address, regardless. Now keep in mind that most home Internet providers have the habit of restarting your public IP address every day.

Next, you give me your application port, for example. 8080.

So, I will try to get https://104.16.34.249:8080/ (or http://104.16.34.249:8080/ , depending on your application).

But in most scenarios I wouldn’t hit either your router. So, step 2: tell the router that it sends traffic on this port to your computer. You may have a simple port forwarding configuration or for example. put the computer in the dmz. (How to do all this is another question, perhaps on ServerFault or SuperUser).

So now I can access your application from interwebz.

But you probably want me to use some kind of permanent name, not a permanent IP address. This way, you register for a service like DynDNS or No-IP, and install your little fragment on your computer or router, and they give you something like a home host name, for example. http://best-home-webserver-that-will-never-run-out-of-electricity.dyndns.com/ or http://my-cool-app.no-ip.com/ .

Talk about activating your game, huh?

But what if you want a "real" domain name, your own, for example, " http://i-have-webz.com:8080/ "? So, your next step is to buy this domain from someone like Namecheap, and then configure DNS to indicate your IP address (if it is static, that is, if it does not change constantly) or as an alias to your no-ip / dyndns (dynamic) hostname.

The next good step would be something like getting the right UPS, as well as a diesel generator, when you did not have enough power, renting another DSL line from another provider in a different cycle (so that you have, for example, one cable and one fiber optic line ) to back up, or perhaps borrow wireless access from your neighbor for this purpose, introduce cyclic dns material growing from it a huge business, and then transfer it all to Amazon.

What is described above are high-level steps for just one way to process your script. This is not a very complete path, not exhaustive of possible traps. There are many, perhaps better ways to do many or all of the steps.

+3
source

you can use nginx and add the configuration to your nginx proxy to your node js this is a configuration example with nginx

 server { listen 80; server_name example.com; location / { proxy_pass http://APP_PRIVATE_IP_ADDRESS:8080; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection 'upgrade'; proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; } } 
+1
source

This method is not recommended constantly, but for demonstration, testing, you can open a port in your router, and another (from the public Internet) can access it. Use some kind of dynamic free DNS, like no-ip, to map to a domain if you need a domain. Hope this can help you.

0
source

Source: https://habr.com/ru/post/1241691/


All Articles