How to add a hostname to the LAN so that a Ruby web server, such as WEBrick can serve off that hostname? - ruby

We can use Ruby and WEBrick to start a local web server, just by
ruby -run -e httpd -- -p 8080 .
I have seen some iPhone / iPad app being able to add a hostname of http://awesome.local:1234 on the LAN, so a local Mac, and other computers can connect to it. How can we do this using Ruby, adding the hostname and add it together, if possible, with WEBrick?

It is not possible to do anything with Ruby to do this, because this is not Ruby's problem. Computers deal with translation of host names to IP addresses in two different ways: hosts file and a DNS query.
hosts file is a way to tell a specific computer what addresses it knows about. You edit the file, put in what name maps to what IP address, and when that computer makes a request to one of those names, it knows who to contact. Since you need to have the record in the client's computer, there is nothing you can do on the server to affect it, which is why no amount of fiddling with Ruby or WEBrick will help. Also, iPhones don't have a hosts file you can edit.
When a computer does not know a name, it asks someone who does. This someone is a DNS server, a sort of smart Yellow Pages for computers. Your computer has a DNS server it is configured to work with; if it does not know, it will ask other DNS servers for the information. Notably, the router of your LAN almost certainly has DNS functionality.
Thus, the normal way to do what you want to is to tell your router which address it should tell everyone when asked about awesome.local. How to do this is both off-topic for Stack Overflow (as it is not a programming problem; you could ask on SuperUser), and impossible to answer without knowing the exact make and model of your router.
EDIT: Given that your example involves an iOS device, there is another answer: : Apple devices use Bonjour to yell their own configuration data at each other. It's not the app doing it, it is iOS. You can install Bonjour on most other operating systems. There is also a Ruby gem that implements Bonjour protocol, dnssd. I have not worked with it, so I can't tell you whether or not it will solve your problem.

Related

socks5 proxy: enable for only certain IPs

I have a webpage and a little game server running on my own machine that is located at my work office.
The problem is that some people can't reach the webpage and game server, because of some network issues. The reasons are not the key, just take it (for almost all my community all things works fine, there just some troubles for a specific group).
So,
I have set up the test Droplet on Digital Ocean, with socks5 proxy installed.
https://github.com/hensly/socks5
And it all worked :) Clients that are restricted to connect directly are just using my proxy server to connect to the webpage or game server.
.
So my questions come up:
How can I limit my proxy to work only with certain IPs? Actually, I need only one IP - the IP of my server-pc, and that's it (the reserved (white) IP and domain name attached to it). Is there a way of such limitation on the proxy side? I just don't want them to use proxy for everything (mostly because there is not an unlimited Bandwidth and it could cost some extra).
Thanks <3
p.s. if you know other, more convenient ways to solve my problem, I'd appreciate it if you share your thoughts.

Is there another possible way to display a webpage(selfwritten) not on localhost but on any mobile browser other then paying for a webserver?

I am starting to write my thesis and I will work using Blender and Three.js for the project. As it will have a gps functionality it would be better to run it on mobilephones' browsers. I would like to know if there is any other way to do that then through a paid webserver, or without simulation or there isn't.
One option is to use a computer on your local network instead:
Set up a web server on your computer. Popular choices are nginx
or Apache.
Copy your files to the directory used by your web server.
Find out the IP address of that computer.
Enter that IP address in your mobile browser.
Of course those steps are very general, the concrete details depend on your operating system.

HIding behind a proxy did not seem to work?

I often visit various sites and like to do so anonymously from behind a proxy. However, it seems as if some websites are still able to detect my real IP address. I know this because they use the IP address to attempt to geolocate me for services.
How did they actually get my real IP Address if I am using a proxy?
How can I truly hide myself?
Most proxies you'll find online are so-called 'transparant proxies'. This means they identify themselves as proxy and even give your real IP-address to the site.
These proxies are commonly used to load pages on the proxy-server instead of your PC.
IP proxies won't protect you at all, to be honest.
What you need are VPN's (Virtual Private Networks) a.k.a. Network Tunnel.
VPN's allow you to do everything online via an external PC inside that network. You'll get that PC's IP and all loading etc happens on that PC.
Not all VPN's are undetected. If you always want to browse the web anonymously, you'll need to find some HQ VPN's (barely for free) and you'll need to change VPN frequently.
Try searching on HideMyAss, SecurityKISS, ... or maybe even the TOR-network

My IP seems to be blocked by web hosting server

I have a strange problem, I just installed my php web site on a shared hosting, all services were working fine. But after configuring my app I just could visit my web site only once, other attempts gives:
"The server is taking too long to respond.".
But from other IP i can access, but only once, it seems all ip addressess beeing blocked after first visit(even ftp and other services get down, no access at all from the IP), can anyone help to explore this problem ? I don't think that it's my app problem, the app works fine on my local PC.
Thanks.
First thing to try would be a traceroute to determine where your traffic is being blocked.
In a windows command prompt:
tracert www.yoursharedhostingserver.com
At the moment, trying to access this address gives this:
Fatal error: Class 'mainController'
not found in
/home/myicms/public_html/core/application/crApplication.class.php
on line 181
I have tried it multiple times and it didn't block me. It might be that You have already solved this problem.
As far as I know, the behavior described by You could only be explained by a badly configured intelligent firewall. It may have been misconfigured by Your host.
If You visit a site at a certain host and suddenly You cannot access an ftp on this host, then it's either a (really bad) firewall or a (very mean) site that explicitly adds a firewall rule to ignore that address.
Some things that You might look into:
It might be something with identd too. What was the service You have configured on Your host? Was it by any chance any kind of server-controll panel (that might have an ability to controll a firewall)?
Is the blockade permanent, or does it go off after 24h, or does it only go off after rebooting the server? Does restarting some services makes the blockade go off?
Did You install any software that "protects Your server from portscanning"? It might be a bit too aggressive.
I wish You good luck in finding a source of this problem!
Chances are that if you can access it once that its actually working. The problem is more than likely in the php code than in the server.

Forwarding only on a single port 8080 to localhost (windows) possible? [closed]

Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 10 years ago.
Improve this question
I know how to set up a local webserver using xampp on windows... I enter my alias and target on the hosts file (c:\windows\system32\drivers\etc\hosts) and then add a respective entry on my apache vhosts config file. This way, assuming that my webserver is listening to port 80, I can for example map example.com to my local webserver.
I've always entered the whole domain name (that is e.g. example.com) in my hosts file and any requests on that name would be directed to localhost.
Now I was wondering if there's a way to only forward example.com on a certain port (for example only example.com:8080) to the local webserver, and leave example.com (on the default port 80) alone, so that it would still go to my live production website.
As far as I understand this might not be possible using only the hosts file (I tried adding the port :8080 to my domain names - didn't seem work ;-) )...
I really don't know much on this topic so any ideas, insights, links, reading material, tools are welcome.
Edit:
Arnout's reply answers the question I've asked above but doesn't solve my actual problem. Rerouting example.com:8080 to localhost:80 does work and if I access example.com it loads up the frontpage of my local version, but all links on that page of course don't know about the port number and therefore point to the production version... The actual solution to my problem seems to be to bite into the sour apple and fix my application (following Rob's suggestion) and remove all hardcoded urls, so that it works on any domain...
Internet Junkbuster (a proxy server) can do this using its forwarding functionality.
Just add a line like
example.com:8080 localhost:80 . .
to sforward.ini, and uncomment the forwardfile line in junkbstr.ini. Now configure your browser to use a proxyserver running at port 8000 of localhost, and you're set.
I'm sure other proxy servers have a similar feature — I just like Junkbuster since it's a simple standalone executable.
You are playing in the area of domain name services (DNS). Technically, with an advanced DNS configuration (which can include remapping ports), what you propose is possible and it is done routinely on the Internet. However, it is unlikely that you would want to go to that much trouble and expense locally.
On the other hand, I suspect that your real issue can be addressed more easily. Why would you want to have "example.com" resolve to your local web server? You can already reference your local web server as "localhost", as "127.0.0.1", and via its assigned machine name "workstation-x".
The only reason that I can think of, and that I have seen, for wanting to reference your local web server with the same host name as your production web server is due to hard-coding the server host name into your links within your application's web pages. If that is the case here, the answer is simple: don't! You should ALWAYS implement your web applications so that they reference everything (other pages, CSS, JS, images, etc.) relative to the deployed server. If you deploy across multiple servers, then your references must be absolute based on configurable server host names. This is easy to do, and there is no reason not to do it.
If this is not the case, then please explain what you are trying to achieve and what motivates you to try.
EDIT: Since you have confirmed my guess that the problem is hard-coded references to the production host name in the web pages, let me simply add that I have ALWAYS, WITHOUT EXCEPTION, found that it is cheaper to fix the real problem than to accumulate workarounds (such as your attempt to remap ports). I have never encountered an author who has argued the opposite.
Fixing the pages should be little harder than a global search & replace, especially with a decent text editor. Even writing a simple script to change the source files would be vastly cheaper and easier than your attempts at a workaround.
Regardless, best wishes to you, and let us know how it turned out.
Can you confirm if 8080 port is listening on webserver? use the command "netstat -na" to see if the port 8080 is listening.
Did you add 8080 port on apache config file as the same as the default 80 port?
Once you add port 8080 on apache config file to make it listen and double check if 8080 port is listening on webserver, then you will be able to access the page using port 8080. like http://mytestwebserver:8080/index.html or something like this....

Resources