Access broccoli server from other device - broccolijs

I'm using broccoli to develop a simple app and I'm trying to access it from a mobile phone.
However, even if I'm able to access the site from my computer at localhost:42000 I'm not able to do so when I point the browser of my phone at 10.0.1.8:4200.
Is it possible to access the broccoli server from other devices? If not, how do you suggest me to handle this issue?
Thanks

Well, localhost is 127.0.0.1, which is not accessible from outside your computer by default, but... You can use a development proxy like Pow to fix this.
Pow is very simple to setup and configure to your needs and apart from that awesomeness it can serve your apps to other devices on the same network.
What you need to know before you proceed with the steps below:
Your computer's IP address on your LAN.
The name of your app.
For the example steps below let's use the following values.
IP: 10.0.1.8
App name: magicapp
Steps to happiness (if you run OS X or Linux):
Install Pow with:
$ curl get.pow.cx | sh
Tell Pow to look for your app at localhost port 4200 with:
echo 4200 > ~/.pow/magicapp
Voilà. If all went well, you should be able to access your app from other devices on the same network at: http://magicapp.10.0.1.8.xip.io/
Hope this helps.

You could simply launch the broccoli hosting server via
broccoli serve --host YOUR_IP --port YOUR_PORT

Related

I want to turn my localhost server into a real website

I created an application that runs on a localhost server using expressjs. And I also bought a domain.
I'm wondering if there is a way to take that localhost server and turn it into a real shared server
I tried once to use a hosting service like hostgator but I still don't know how I can turn the express app into a real website.
I have no experience with any web development services so please don't tell me to use ....... whatever because I will have no idea what that is.
For one thing it is not clear how your website actually works: if it is only express does it generate HTML or is it purely JSON passed to browser clients via get requests (to each their own).
There are so many options as to how you might do this: one of the best options is to first make sure your server runs on Docker. Find a tutorial on YouTube/google/Stack Overflow/Blogs on how to run your Express server with docker. If you do that you can deploy it to a Container manager like Google/Amazon/Digital Ocean. If this seems hard to you there are other options.
Presumably you run your server with something like npm start. This guide can show you how to do essentially that but on a cloud computer.
Before you begin make sure that you're locally working server is checked in to a cloud Git provider like Github, GitLab, Bitbucket, etc.
Since Amazon AWS, and Google Cloud have free tier or options for hosting for free for a certain amount of time (AWS 1 year) or for a certain amount of money (Google Cloud). These two seem like viable place to start.
If you find the option that you'd like you'll need to:
create an account
Create a server (choose a cheap one especially initially like mice/small/cheap etc).
Find a tutorial on how to "SSH" into that server (which basically means remotely control the terminal on that server). Google actually makes this fairly easy there's a big button that says SSH into this server.
Once you've logged into that Computer you'll be able to run the same commands you probably normally do on your home computer:
The computer you'll be getting is likely to be a virtual Linux Computer probably something like Linux Ubuntu. Find a tutorial on how to get git and node installed there (but it's something like sudo apt-get update && sudo apt-get install git node).
Once you have git and node try mkdir www and cd into that: mkdir www && cd project (This isn't critical but conventional.)
Copy the link that allows you to "Clone your repo using HTTPS" (there's a link at the top right of your GitHub (or others) repo that allows you to do that. You'll need to enter your password
Now all the files that you had on your computer are on this new computer.
Next you'll have to probably npm i to install your dependent NPM packages. (This assumes you properly used .gitignore to prevent GitHub from being filled with extra copies of your npm packages.)
Now you should be able to run your code as usual: npm run start
If all those steps work you'll want to get something that will run these "forever" like https://www.npmjs.com/package/forever npm i -g forever or even better: https://www.npmjs.com/package/pm2 will allow you to continuously run your express server.
Finally, you'll need to configure this server on AWS/Google/whatever service you're using to push traffic coming in on port 80 and 443 to port 3000 and open traffic to all. And depending on the service you chose that's different so find a tutorial for doing just that part.
This will only allow people across the internet to see your service on an AWS URL or a google URL. But it's a good chance to make sure everything works perfectly. Once you're happy with everything associate your purchased domain with that special AWS/Google domain. You can do that on the AWS side, or the GoDaddy/NameCheap/where-ever you bought your domain side.
For the docker option you can download aws-cli tools and upload your built docker container to AWS and have it available. Find a tutorial to do that.
Essentially your question is very broad so I sometimes brushed over some details, but this is essentially what you have to do.

Creating RESTful server for raspbery pi 4 to display images

I got a task and have absolutely no clue on how to do it at the moment.
I watched a couple of tutorials on REST API, but none of them are applicable for my application. I don't intend to use a localhost, but if it's required then sure.
What is this task?
So there are two parts.
PC (client)
Raspberry Pi 4 (server)
Here’s the sequence:
The PC is the client and sends a request to the server, which is the Raspberry Pi 4, to display an image, let's say image1.jpg. The rpi4 is connected to an external monitor via HDMI.
The server/Raspberry Pi 4 receives the request and opens up image1.jpg which will then be displayed on the screen in full screen to be shown on the screen through HDMI.
Perhaps there is a better solution than to use RESTful API to solve this. If there is please give me recommendations.
There are 3 parts to this:
capturing an image
displaying an image
telling RasPi to do both the above
In order to capture an image you can use raspistill or libcamera utils in newer versions of Raspberry Pi OS.
If you aren't capturing pictures with the camera, you must presumably be supplying them from the PC. So you can either use scp to copy one across from the PC:
scp SOMEIMAGE.JPG raspberrypi:image.jpg
Or you can use a Windows SHARE to share a directory between the PC and the RasPi. In Windows you'd use the "Share Folder" option and on the RasPi you can use smbclient or cifs-utils to mount it. Example here.
In order to display an image, either use raspistill built-in options, or use fbi or fim or feh depending on how things are connected and whether you are running an X11 server or not.
In order to tell RasPi to do the above, just use ssh (or Putty on Windows) like this:
ssh user#raspberrypi 'raspistill ... -o /tmp/image.jpg; fim /tmp/image.jpg'
Note that RasPi implements avahi, so if your Raspberry Pi's hostname is set to simon, you should be able to talk to it under the name simon.local on your network, so the command above would become:
ssh user#simon.local '...'
where user is your username that you login to your RasPi with.
You can set your RasPi hostname with:
sudo raspi-config

Why using NGINX or how to deploy Meteor app correctly?

I am going to finish my Meteor app in a few weeks. So the problem that I will face - how to make my app available to other people.
Firstly I bought a droplet on Digital Ocean. And started to read about the ways to deploy meteor app to production server.
I found 2 totally different ways to do that!
The first one is pretty simple (and so I really love it). Here is the link. I have to do a few steps - create a droplet with Ubuntu 14.04, then connect to this droplet via ssh, then install and run mup. After that anybody can access to my app. I worry, that there is no ssl support (my project is e-commerce, so I really need https-connection), but then I found in mup docs a short article How to set up SSL with Mup. So everything is perfect at first glance.
But then I found another way to deploy meteor app. Here is link. It is much more complicated. First I need to install node and mongo on my droplet. Then install and configure nginx. And then after many steps comes Meteor installation. Author don't explain why people need do deploy app this way, assuming that it is obviously to everyone. His explanation is "The problem with this is that it isn’t wise to run an application like Meteor through your public port (which is 80)".
I admit I have no experience and knowledge in such questions. The one thing that I can say exactly is that I need a really proper way to deploy e-commerce meteor app. And it doesn't matter I won't sleep many hours by doing this.
So question is: which one way is proper? And (it is important) why?
Either security and performance are important for this project. I am also going to use prerender.io or spiderable (for seo purposes) and fast render, if it can have an influence on your answers. and really thank you for answers guys!
You can deploy your Meteor App on server via different mechanism . There are lots of way to do the same thing.
Like as you said you also found two ways to do that.
So in first link you used Meteor up for deployment your application as you successfully deployed .
In second approach you need to first login to the server and than create user than install everything needed to your server machine after that you need to setup Nginx.
So as i guess your question is related to "Nginx" . And you want to know
1)Why we need to use Nginx
2)Which one is the better approach
So answer for your first question is as follows:-
Nginx (pronounced "engine x") is a web server that is used for many purpose mainly use for proxy pass. Means using nginx you can redirect your request from one url to another and the actual url is hidden from the UI (For securety purpose and for redirection).
Like in meteor your app is by default running on 3000 so one way is that you can open 3000 port and run your application on that port. But via nginx you can run your app on 80 port and as user hit any event than in nginx you can configure address where you want to send your request.
Like you can send them to 3000 port.
So now user don't know in actual where is your request going on because you show them port 80 but in actual your request is go to 3000 port. So this is the one advantage of using nginx same there are lots more.
So for configuration of nginx you just need to install nginx if you are using ubuntu than via simple command-:
sudo apt-get install nginx
then setting in nginx configuration file that is under the following directory:-
/etc/nginx/sites-enabled/default
just open this file and setup up your configuration here like:-
server {
listen 80;
server_name localhost;
root /home/parveen/meteor/app;
location / {
index /index.html;
}
location /api {
proxy_pass http://localhost:3000;
}
}
In this way you can configure your nginx setting as you want please read nginx documentation for detail.
After that you need to start your server using forever or nohup which you want to use so that your server will not stop as you exit from the login of server.
Conclusion:-
In the second approach you need to install everything by yourself via ssh login to your server than configuration of nginx and and then run your server.
If you do any changes than again you need to update your changes to server and then stop meteor app then restart that. But this is more secure approach and you can do what you want to do.
In first approach they are using mup (Meteor up) that do so many of works for you . You just need to do some configuration you can use Docker or as define in the blog (droplet) link you shared and just need to run meteor up command and that will first create a bundle for your app than run that so in the first approach if you do any changes than you not need to login again to your server update changes , what you need to do is just run again the same command and that will create new bundle with updates and run your project. But i don't think that is more secure.
So its depend on your requirement and choice which you want to use.
If you have any question than most welcome.
Hope this would help!
Thanks

Unable to access my webserver (virtual machine, Ubuntu 14.10) through browser

I have setup a Virtual Machine on my Windows 7 system (Ubuntu 14.10). It looks like Apache, MySql and PHP have been installed successfully. If I ran
curl -l 127.0.0.1
I see the website in my console.
But if I hit this address in my browser I just get "This web page is not available".
VM->Settings->Network: I've selected "Bridged Adapter".
Have anyone any ideas what could cause the issue? Any help will be much appreciated. Thank you.
If you are trying to access to 127.0.0.1 it's not gonna work. You have two solutions :
With a bridged interface, go to ubuntu, open a terminal and type ifconfig (it's possible you have to be root for that). Then use the ip displayed.
You can add an host only interface and do the same thing

Access my MAMP websites (plural) locally from my iphone

I have created a few websites locally on my mac using MAMP PRO as my local server environment.
I can access these on my mac as I have the opion of adding a local domain (in MAMP PRO) using "local name resolution"
But... I don't know how to access my sites from my iphone which I need to do to test.
If I put my local IP in (on my iphone) I get the MAMP holding page:
The virtual host was set up successfully.
If you can see this page, your new virtual host was set up
successfully. Now, web contents can be added and this placeholder
page1 should be replaced or deleted.
Server name: localhost Document-Root: /Applications/MAMP/htdocs
So I know that works but how do I access my indevidual sites.
The location and structure of my sites are like this:
/Users/myusername/Sites/vhosts/site1/public_html
/Users/myusername/Sites/vhosts/site2/public_html
/Users/myusername/Sites/vhosts/site3/public_html
/Users/myusername/Sites/vhosts/site4/public_html
Could this be to do with the localhost Document-Root? I noticed it was /Applications/MAMP/htdocs
Should I change that or change the location of my sites to be in /Applications/MAMP/htdocs?
Thanks
C
UPDATE:
Ok, so I changed my Document-Root to /Users/myusername/Sites/vhosts/ which now allows me to load the site localy in my browser with 192.168.1.134/site1/public_html
BUT.. when I load 192.168.1.134/site1/public_html from my iphone (on the same wifi network) I get the page title but the page doesn't load. Just hangs!
I use ngrok to forward my localhost and would recommend it. After installing it (it's free), you essentially run something like "ngrok 80" and ngrok will create a public URL that can be accessed from anywhere (AKA your phone) and displays the same content that http://localhost/ would.
Apologies I can't post full http:// links- I'm limited by my reputation.
In your example, ngrok might create a domain "hs673gs.ngrok.com" that corresponds to "localhost" when accessed from your local machine. Going to "hs673gs.ngrok.com/site1/public_html" from your iPhone will be essentially the same as visiting "192.168.1.134/site1/public_html" on your local machine.
Hope this helps.
MAMP has launched an app where you can see your local websites on your mobile through their app MAMP Viewer: https://itunes.apple.com/de/app/mamp-viewer/id1047237620?l=en&mt=8
You just configure the host that you want to use for MAMP Viewer:
Select the host you want to view on MAMP Viewer > On General tab, make sure to check, "for 'MAMP Viewer' (LAN only)" > click save > restart your servers > open the app and check your sites.