Can i run a second web server? - python-3.x

So i own a raspberry pi server which runs a python web server i want to run a second web server on the pi but im not sure if it can handle it.
Raspberry pi 2 model B,
Python 3,
Ubuntu Software,

Short answer: Yes, you can.
Long answer: It depends on what your web servers will be doing and how good your internet is. I have a RasPi 4 running OctoPrint, a few bots and some other misc. stuff. Also, you may run into problems along the lines of your web servers trying to listen for connections on the same port, which is another problem outside the scope of your initial question.

Related

how to communicate with my apps using IP address and socket remotely

I am to Electron and nodejs
And stuck here, actually i m making a desktop app to control every PC in network. which tells me the ip and mac of computers in the network. But now I need to talk to it and push/get some message. but how ?
Socket.io is likely the easiest way to do what you are trying to do. It'll allow you to communicate between the machines with a relatively low amount of effort.
Sockets generally work on a "server" and "client" basis, so you may want a central server that will coordinate with the clients.
This blog post from node source provides a really good intro to using them.

access to a raspberry pi from all over the world without dyndns

first of all i wanted to clearify, that i'm not asking, how to access a raspberry pi from the internet. I know, that I have to use a DynDNS or the IPv4 if it won't change. But I can't use this.
So I will explain my problem:
A friend of mine and me are working on a project. We are creating a automatic watring system for gardens or plantations and we have a apache on the pi, so you can access the pi from the home-network. But we also want to access the pi from outside, but without using a DynDNS, because we want to make it marketable, so you can't give every pi a DynDNS.
At networks, where the IPv4 won't change it is not a problem, but usually the internet provider change your IPv4 nearly every day. We also thougt of building a own small server with old PC-Components of our parents, but we don't know how to deal with the changing IPv4. Theoretically we could build a own small server if it is a solution.
So I wanted to ask you, how to access a raspberry pi with changing IPv4 without DynDNS.
(Sorry for my bad englisch)
Your bigger problem is that 99% of consumer devices are behind a router. You will need a solution that opens a connection to your service and waits for commands. This concept exits with tools like netcat or ngrok.

CGI version of expressjs

I want to create a small web service and for that I really want to use node.js and express.
I already have an Apache running on my little server (it's a Raspberry PI :P ) which receives all the traffic. How can I configure a VirtualHost to be served by node.js?
I searched a lot and I found many solutions, namely:
Use ProxyPass to forward requests from Apache to node.js
Use Rewrite rules in .htaccess file
Use VPS
But all these solutions require a running daemon for node.js and resources are scarce on Raspberry PI (it only has 256MB of RAM). So I searched a bit more and I found this solution:
GGI-Node provides the ability to run JavaScript on any web server just like PHP as a CGI using Node.js.
But again, this solution doesn't fulfill my requirements. GGI-Node is more of an adaptation of node.js to PHP and it's not possible to use with/like express.
So I came up with an idea: what about modifying express to keep the same behavior and functionality and, instead of creating a server, feeding express with info from Apache via CGI? I searched even more and I didn't find anything like that... Is this possible to do? How hard would it be to implement?
I know this solution doesn't take the advantages of node.js asynchronous I/O, but it's not important in my case.
Here's one possible solution: Get another Raspberry Pi or two :-)
No, I'm not kidding. Here's what I'm thinking:
With one additional Raspberry Pi:
Set up the Raspberry Pi running Apache as a proxy for your new virtual host & route all the traffic for that virtual host to Raspberry Pi #2. Set up node.js and your express application on Raspberry Pi #2.
With two more Raspberry Pis:
Leave Raspberry Pi #1 as is (with Apache & whatever other web site you have running on it).
Set up Raspberry Pi #2 with node.js & your express application
Setup up Raspberry Pi #3 with a proxy and proxy requests to #1 & #2. Apache can do it, although it's a pretty "heavy" solution - I'd go with nginx personally.
Actually, you could do it with just one Pi
Set up the Express app to listen on some arbitrary port & use Apache to proxy requests to the new virtual host to that port.
However...
How ever you do this, be advised that the Raspberry Pi (at least the earlier models) are not good at running node.js. I tried this (running an Express app) with an original Raspberry Pi and performance was not good (I wound up rewriting the code in go). You might have better luck with a Pi 2 or a Pi 3.
If you decide to go this route...
Here's a link to a Digital Ocean tutorial on using Apache as a proxy. I haven't followed this tutorial, so I can't vouch for it, but a cursory glance suggests that it's pretty complete.

How do I host a NodeJS http web server on a raspberry PI/or any linux based PC

I've seen people host Apache servers on raspberry PI's and of course on regular computers. I do not wish to or rent a VPS and thought it would be best to set one up on my Raspberry PI 2 B:
(1gb ram/32gb disk/1ghz on overclock)
What is the proper way of setting up a NodeJS http web server on a computer? Can you link me to a tutorial if one exists(Couldn't find any).
I was also wondering if I would be better of renting a VPS with recurring costs and lack of customization/control , or on a working dedicated PC. Keep in mind that I wish to practice some dev ops work over multiple PI's(ex. Chef).
I need this server to be accessible through the internet through an ip or domain. How do I go about setting that up? (I have domains)
Update: I wrote a blog post on this subject.
The tutorial goes through the full installation process. Click the link below
Yes, You can use raspberry as your VPS or dedicated server. Just assign static IP address(You need to buy) to your Raspberry and then point your domain name to that static IP address.
Few links below that will be helpful for you,
https://www.modmypi.com/blog/how-to-give-your-raspberry-pi-a-static-ip-address-update
https://in.godaddy.com/help/point-your-domain-name-to-a-server-19116

Local pi server running node and websockets

I'm just wondering is it possible to run a local server using node (node would be running on a raspberry pi) and communicate with it via a web browser on a different machine on the same network using websockets? I'm looking into using a browser as a control system for a project I'm working on. If it is possible is there any references I can look at?
Thank you,
Techhead55.
EDIT
I already have node up and running on the pi, it's just that I'm not sure if you can and how you implement a local server and use sockets to communicate with it in a bowser on the same network.
Not sure if you specifically ask about Node, but here is an example of a WebSocket server running on Pi, and browsers connecting to that server: http://tavendo.com/blog/post/pypy-on-the-pi/
The example does Publish & Subscribe over WebSocket using WAMP (http://wamp.ws).
Here is a similar example running on Arduino Yun that shows how to connected hardware, and publish data in real-time via WebSocket, receiving data in a browser, and real-time rendering a chart: http://tavendo.com/blog/post/arduino-yun-with-autobahn/
Disclosure: I am original author of Autobahn and work for Tavendo.
Yes.
Here is great manual from Matthias Rüedlinger:
http://blog.rueedlinger.ch/2013/03/raspberry-pi-and-nodejs-basic-setup/
Also installation of ghost with node on RPI is very nice :)
http://bit.ly/1cFwFAQ

Resources