socket.io setting for ip on local network - configuration

I have a socket server running on port 8000 on my local machine and it is connected to the router via dhcp
My app runs fine but when i get a different ip from the router I have to change the ip for the include in the script
My router unfortunately doesnt have the ip reservation feature
<script src="http://192.168.2.3:8000/socket.io/socket.io.js"></script>
<script>
var socket = io.connect('http://192.168.2.3:8000');
</script>
Is there any way I can get away without hardcoding the path. (I cannot use localhost because if I try to use a different computer it doesn't work then)

I used the solution from #Curious. I set a range in DHCP and used an IP outside this range.

Related

Setting up MySQL database behind a VPN address

I have a regular MySQL server running with XAMPP at port 3306 and accessible by my internet ip aswell my local ip (127.0.0.1), the ports are forwarded in my router. An account set up to be accessed from any IP, Everything works fine.
I'm trying to make this same server be accessible by AirVPN DNS address. So I've followed AirVPN instructions to remove the forwarded ports in my router and forward a new port at their VPN with a random number (lets go with 1111) with local port as 3306 and DNS named as xxx.airdns.org
So I open MySQL with XAMPP under port 3306, nothing changed in config file. I run the AirVPN port checker over 1111 and it signals as open. I also try at other sites that checks ports and signals open at xxx.airdns.org:1111
Though when I try to make a connection as usual it returns error (10060): Can't connect to MySQL server on 'xxx.airdns.org' (10060)
Resolutions I've tried:
Switch port values in MySQL config files matching with the ports open in AirVPN
bound address to VPN adapter bind-address="10.6.114.48"
repeated the options above in all different kind of port combinations and addresses
Disabled Firewall on Ethernet adapter of VPN as described here
I couldn't achieve success in this task. I'm looking for some enlightment so I can understand the process.
EDIT:
The connection is set only to TCP protocol. A port check done through airVPN and is registered at XAMPP & FIREWALL logs as accepted connections. Though trying to connect from a client I got no log from Xampp or Firewall, it gets timed out.
Sorry for "answer" type not just comment, but i dont have enough reputation here :)
Maybe the protocol ( TCP/UDP ) is your issue.
If you use UDP on your airVPN better check forwarding on your router - most of them
by default sets TCP only. Otherwise maybe change to TCP on your airVPN.
ISP provider often filter this protocol.
Issue: Consider that you can't connect to a service running "behind" some VPN server from a machine that's connected to that very same VPN service.
Solution: Connect from another machine to test your service properly.

How to change https default port but not include it in the URL

I have a website on 2 different servers. And I would like to access the site on server #1 by going to https://www.example.com/ (on port 80) and access it on server #2 by going to https://www.example.com:4567/
But the problem is that I need to hide the port number from the address bar. With port 80 it is hidden by default. But if I change it to a different port then it is visible. For example if I do console.log(window.location.href) on the server I will see https://www.example.com:4567/ (with port included).
Is it possible to tell Google Chrome that the default port is not 443 for HTTPS but instead 4567? I could not find anything in the settings that could do that.
I think I found a solution for my problem. Although it requires that I access the website from a specific IP address.
I was able to set up port forwarding in my router in such a way that all incoming requests from my IP address get automatically forwarded to not only a local IP but also a specific port number.

Access to mysql server from external network (xampp)

I downloaded xampp and made it work(mysql, phpmyadmin) in internal network.
Now I want to make it accessed from external network ,But I want only the mysql server to be external accessed and phpmyadmin only internal.
How can I do it? port 80 / 8080 is already in use in router so I need to use another ports , does it matter?
You should be able to open up port 80 on your router. go to the port forwarding setting and make the external port 80 if you just want to type in your ip address when connecting to your computer. Otherwise, change the port to whatever you want and set the internal port to 80.

Google Cloud HTTP Load Balancer can't connect to my instance

I have created a HTTP load balancer to basically redirect from port 80 to port 8080. The server on my instance is running on port 8080.
I can connect to the server directly but the LB is not able to connect to the instance, both accessing the LB's IP directly and also the health check always fails. The instance group the LB is using consist of just that single instance.
I read Google Compute Engine health checks failing
and the google-address-manager is running. However, when running ip route table list local there is no routing for my LB. The user in the above question is using Network load balancing and not HTTP load balancing (as I am) so I don't know if that is related?
Or perhaps it's related to a firewall? I have added my LB's ip address to a firewall rule that allows tcp:8080
Does anybode have any idea how can I fix this? I am not experienced with debian nor gcp.
Show I just try and run the route add command referenced in the above question? If so, how come the google-address-manager is not adding the route?
Thank you in advance!
You need to make sure that your port mapping on instance group is set to correct port, the 8080 in your case.
First, edit your instance group and change the port name and port to 8080:
Then, navigate to your http backend's settings and change the default port to the port name you've configured in your instance group.
Finally, make sure that your firewall rules allow access on port 8080 from 0.0.0.0/0 or at least from the IP address of HTTP load balancer (130.211.0.0/22)
I had the same issue and fixed it by adding a firewall rule for the health checker (which is not the same IP as your LB!). See https://cloud.google.com/compute/docs/load-balancing/health-checks?hl=en_US#http_and_https_load_balancing for instructions.
In my case, I did not configure the HTTP health check correctly.
I used "/" as path, but on my backend, "/" redirects to a login-page (HTTP 301), which responds with a HTTP 200.
The health check does not follow a redirect, every HTTP response code != 200 is assumed unhealthy (from Debugging Health Checks in Load Balancing on Google Compute Engine).
So, I changed my path to "/login", this fixed my issue.

Localhost database connect from other sysytem

I am testing a website which in other machine like 192.168.0.1 in my machine which is 127.168.0.2 so in the website ajax jquery is used on page load in which the url is
http://localhost/Demo/store.php
but when i execute that page in website in other machine the database isnt connecting and even if i give the url as
http://192.168.0.1/Demo/store.php
its not connecting to database..What is the issue please tell me...How can i access from other system so that all my local database values can be displayed in other machines also..Thanx..
From http://technet.microsoft.com/en-us/library/cc940018.aspx:
address 127 .x.y.z is reserved for loopback testing and interprocess communication on the local computer.
Your probably not connected to your network correctly. Check your physical connection (blinking leds), then make sure you have a DHCP server on the network, otherwise assign a static IP.
After this try pinging the address to make sure the 2 hosts can see each other. Also open up any ports which may be behind a firewall, 3306 is default for MySQL DB.