How to use local macbook server to allow multiple devices to view Reactjs page? - reactjs

I have a local server running Reactjs on my Macbook. (newbie in React)
1) How could I change the http://localhost:4001 name to something else (e.g. http://www.test.com)
--> I'm using webpack-dev-server --port 4001
2) How could I allow up to 500 iOS/Android device to connect to this local server? (e.g do how to setup a router to broadcast this?)
--> Found this ReactJS-and-ngrok but not sure what's the concurrent users it's able to support.
3) How to allow the device to connect to a wifi without internet access?

First, see what IP is your Macbook in your local network. System Preferences->Network. Suppose your Macbook IP is 192.168.1.70 and your server is on 4001 port. Then you can start your webpack-dev-server with the following options: --output-public-path="http://192.168.1.70:4001/" --host="0.0.0.0" --public="192.168.1.70:4001". You can still access it via localhost name on Macbook, but on other devices use full IP + port number as address.
Can't say anything about setting domain... may be you can configure your router somehow? Sorry, newer had to face such a task

Related

Reactjs Script Server not available

"React-scripts", a series of scripts from create-react-app starter pack allows me to use "react-scripts-start" to initialize a server.
Everything works fine, the server turns on and I can access it on localhost:3000 or by using the IP:3000
The problem is when I use other devices from my house. I try to connect to the IP:3000 and it doesn't work. I'm getting "Server not found".
Is it a Windows access problem or am I supposed to set up the server?
I managed to solve my issue. For me, it was not in the firewall, not in the configuration files. Instead, it was the router.
Since I live in UK, I have Hub 3.0 from Virgin Media.
The solution is:
1) Navigate to Connected Devices and copy the IP address for your device. In my case it was xx.xx.0.16/24 so I copied "xx.xx.0.16"
2) Navigate to Advanced Settings > Security > Port Forwarding
3) Click on "Create new Rule". For Local IP will be your IP address, local start port & end port 3000; external start port & end port 3000; Protocol choose both; Enabled on
4) Apply changes
Now here is the trick. When I run the command
npm run start
I'm getting a message which says:
You ca now view your project in the browser:
Local: http://localhost:3000/
On Your Network: http://xx.xx.37.1:3000/
I can navigate to that IP address : 3000 on the hosting laptop however if I want to make other devices access it, I must use the IP address set up in the router which for me is xx.xx.0.16:3000

Not able to access a port on ec2 instance for an Angular app

I am working on an angular app using the angular cli to set things up. Running the ng serve command spawns a server at this address <my_ec2_host_name>:4200. When I try to access the page on the browser it doesn't work (connection timed out error). I believe this is because of security reasons so I added the following rule to my security groups for the ec2 instance:
Port 4200 should now be accessible but I still can't get the page to load. Can someone think of how to get this to work?
Start angular with below command.
ng serve --host=0.0.0.0 --disable-host-check
it will disable host check and allow to access with IP
You can set up the host option like this:
ng serve -host 0.0.0.0
The steps you are doing are correct for opening a port via Security Groups in the EC2 console. Make sure you are modifying the correct security group, and make sure that your changes have been saved.
Your container may have additional firewalls in place, so you will want to check the OS documentation. For Example, RHEL uses iptables as a further security measure: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html/Security_Guide/sect-Security_Guide-IPTables.html.
That looks correct. Are you sure that your server is running and listening for connections?
You should ssh to that server and verify that the page can be loaded locally. Eg:
curl http://<YOUR HOST IP ADDRESS>:4200
eg: curl http://54.164.10.123:4200
You should be careful to use the public ip address (eg: IPv4 Public IP when you're in the EC2 console). I've run into problems in the past where I've got a server listening on one IP address (often localhost) and not the public ip address.
Also maybe a problem: Is your host inside a VPC of some sort?

Webstorm localhost from mobile

I can't access my Webstrom localhost on port 63342 from mobile.
I opened the port in Windows firewall and ESET (but port online checkers say me that the port still close).
I checked option "Can accept external connections" in Webstorm (but it caused message that Built-in HTTP server on that port disabled).
But when I check 192.168.0.48:63342 in mobile chrome - it still not available.
Please help.
I'd suggest using a different port (8080, 8090) if you need to access the server from another host. External connections to 63342 are not supported for security reasons.
Here are instruction for connecting to WebStorm internal web server from a different host:
- on a remote host, make sure to install JetBrains IDE Support extension into Chrome
- in extension options (chrome-extension://hmhgeddbohgjknpmjagkdomcpobmllji/options.html), specify the IP and port of the target machine
- on a target computer, start WebStorm, make sure that the port specified in Settings/JavaScript/Debugger is the same as above and 'Can accept external connections' is on. Open your project and run your application
Changing the port number to something else than 63342, does work. However I had some difficulties changing the debug port number. If you have the Chrome plugin, changing the debug port number from Webstorm's settings will not override the plugin's default debug port. Thus, you should right click on the plugin, click "Options", change port number and hit apply. At the same time, you should enable external connections in Webstorm's settings: "Settings/JavaScript/Debugger". Then you can access your web app from your smartphone by specifying the IP and port address of the app.

Public LAMP with a modem and router

I am using an Apache2 with a PHP and MySQL installed on Ubuntu. What I would like to do is to run the server public, to access it from outside my network.
However, I am having trouble configuring it, since I am using a ZyXEL P660HW-T3 v2 ADSL Modem with an IP 90.xxx.xxx.xxx together with an ASUS RT-N16 Wi-Fi router with the LAN address 192.168.1.1.
Could someone help me to set up the configuration file correctly to make the server public?
You need to configure your router to forward port 80 from the WAN interface to 192.168.1.1.

Restrict selenium 2 port - localhost only - no external IP access

I have a headless setup in a VPS where selenium server can run - without X server. However, the selenium port is accessible via port 444 across the internet.
Is it possible so that only localhost:4444 is only allowed and external access is not allowed? Be it selenium command line option or firewall/ip table option.
I usually let the port 4444 open like 2-3 hours while doing testing and I'm afraid of being attacked on that port.
I'm using selenium-server-standalone-2.32.0.jar and behat+mink.
Thanks
Why not trying to close port on WAN interface using iptables or equivalent ?
If you and only you, need to access it using internet, consider setup a VPN.

Resources