Accessing localhost (xampp) from another network? - database

I've been searching the internet the whole day... I cant find my solution.
What I have:
- Xampp server installed en configured
- Working website (local)
- Local ip
- External ip
- Port 80 and 8080 allowed in Firewall
What I want:
- Enter my website and database from any network over my IP address. So, when I am at work, I want to access my website using my (external) IP address.
I am working on a RSS feed in a website and mobile android application, the app is connected (should be) with the website's database. But for this, I need a working IP address.
Can anyone tell me step by step what is have to do? I am not a leek, but not good in English.

Ok, you can access your XAMPP outside of you computer is possible only if you are in same network on which your computer is connected. I mean; consider the local ip of you computer where xampp is installed is 192.168.100.1 then you can access it from any ip like 192.168.100.xyz.
Now if you really want to access it from outside of your network you can set up a VPN or port forwarding.
There is a easy solution is to use ngrok. You can get details here
It is really simple to set up.

Related

Rendering localhost react app on mobile phone

I have been trying to render localhost:3000 (React app) on my phone. I have tried the following,
Connecting my MacBook and the phone to the same wifi, getting the ipv4 address and adding port 3000 to it and accessing that IP address port combination in my phone.
I have tried turning off my firewall.
I also tried npm start --host 0.0.0.0
I am running localhost on my MacBook. My colleague who has a Windows machine is also facing similar issues.
Make sure that the wifi network's wireless settings do not prevent local clients from connecting to each other. There is a setting often called "Wireless Isolation" which is pretty common - enabling this results in clients only being able to connect to the outside internet, but not to anything else (such as other wifi clients) on the network. While this is useful from a security perspective when the network administrator doesn't know whether the devices that want to connect are trustworthy, it blocks network functionality. Go into the router's settings and turn this off if it's on.

Is there a way to connect NextJS app on my phone trough local network in development like Create React App does?

Create-React-App provides a URL that I can connect through my LAN network like this:
Is there a way to expose the NextJS URL through the LAN network?
The server is accessible on the local network, as long as the network is configured properly (and doesn't have something like client isolation enabled). All you need to do is find out which IP address your network's router is allocating to you. On Windows, this can be done by checking the results of ipconfig. On Linux, you can use ip addr. Then, when you want to access the app from another device, just use the IP found above followed by the port set in next.js.
For example, I have a machine whose network IP address is 192.168.1.2. On that machine, I have a Next app running on port 56381.
ready - started server on 0.0.0.0:56381, url: http://localhost:56381
I can access it on my phone by going to 192.168.1.2:56381.

How can i host my react js website publicly on my raspberry pi

i made a react js website and everything is working fine but i can't figure out how to host it on my rasp pi4 and make it publicly visitable by other people. I also bought a domain. So my question is: How can i make my reactjs site public and running on my rasp. Thanks!
You have to configure a web server like Apache and build the React app with npm or yarn. Then copy the build files to the /var/www/html/ directory. You will also have to look into port forwarding your router to your local web server and open it to the public. Just be careful with security.
You need to configure a web server to host the site. Either Apache2 or Nginx (I have a personal preference to Nginx, but either works fine for this). Under Debian/Raspberry Pi OS, /var/www/html should be served on port 80 on all of the pi's IP addresses. Place the site files there and make sure you can access the site from the pi's IP address.
For making the site available outside of your network, you will either need to look at port forwarding, hosting a VPS with a public IP, or using a tunnel. Port forwarding is likely going to be the hardest option and may not always work, but doesn't require any external services outside of your DNS provider. Tunneling is probably the second easiest, and using a VPS is almost certainly the easiest.
For port forwarding, yu will need to verify that your ISP does not use CGNAT, otherwise this will not work. Assuming they don't, you will need to access your routers configuration and set up port 80 on TCP to forward to your pi's IP address. I would assign your pi a static IP address, either on the pi itself, or using DHCP reservations. Next, you need to see if your DNS provider offers Dynamic DNS. If not, you will need to manually update your DNS settings in the case your networks public IP changes (unless you purchased a static IP from your provider). In this setup, you point your domain at your networks public IP. Traffic goes directly between the client's browser and your pi.
Tunneling is a fair bit easier. I personally use Cloudflare for my DNS (I set my domain with my registrar to point to Cloudflare, then used their tunneling tool (Cloudflared) to tunnel traffic from their servers to my pi. There are other tunneling services, but I think Cloudflare's is the best out of all of the ones I used. In this setup, you point your domain at Cloudflare, which forwards the traffic to you via the tunnel. Traffic goes from the browser to Cloudflare to your pi.
Using a VPS is probably the easiest, and your knowledge of working with the pi applies to working with a VPS, assuming you run Debian linux or similar on your VPS. You would install the web server on your VPS, put the app on the VPS, and point your domain at your VPS's public IP. In this setup, traffic goes from the client browser to your VPS. This is the only non-free option (excluding the price of the domain itself), and keeps your local private network safer by not putting public services on it. You can also run a tunnel between your pi and your VPS if you want (see https://www.jeffgeerling.com/blog/2022/ssh-and-http-raspberry-pi-behind-cg-nat for an example), but I don't personally see the point unless you really want the app to be served from your pi.

Open local website on computer from phone on same network

I have a local sandbox website on my computer running on nginx. I have chrome canary and that's what I"ve been using to test the various media sizes. Of course, this doesn't stack up against actual hands-on testing to get an idea of the feel of the website.
So, is there a way to be able to access a website running on my computer from the same network? Even if I have to use a specific app. I would like to use the same URL. dev.mywebsite.com and mywebsite.com run a on a server, sandbox.mywebsite.com is on my machine (this is the one I would like to access). I don't need to access to it remotely, just when I'm on my network is fine.
Note: I need to use the actual URL.
Thanks.
If sandbox.mywebsite.com maps to localhost on your computer, then by mapping sandbox.mywebsite.com in the hosts file of your phone to the local network IP address of your computer e.g. 192.168.1.9, you should be able to access it on the phone.
I have done this using android with hosts editor, connecting to apache running on an ubuntu laptop.
There are also many google results for this, so you may be able to find something there for your specific configuration.

Setting up a local website on wifi router

We have a mobile website developed for a conference which should be accessible to users thru smartphone/tablet/laptop when they connect to a wifi router.
Is it possible to setup a xampp server on a local pc connected to the router and assign it a url, so that users can type the url and access the website?
Will the users have to type an ip address or would it be possible to assign a url?
I read in some posts that one way would be to setup a captive portal but we do not have the time & resources to setup a captive portal. Kindly correct me if I am wrong.
Thanks in advance,
Raghav
I feel like this could be possible by building out a DNS server for the lan. And entry for your webserver would then have to be in there. Then, in the router settings, specify the local DNS server as the DNS that gets assigned to other LAN computers via DHCP. Any node that connects to the router and uses DHCP to resolve IP settings should get that DNS server. Then when a client attempts to resolve www.website.com, it will ask the local DNS to resolve it and the request will be translated to the LAN address. I have never done this before but it may be worth a shot.

Resources