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

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....

Related

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

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.

Redirect to different ports based on request URL

I'm using Windows Server 2003. I have one web application running on IIS and another web application running on Apache Tomcat. Currently all requests go to port 80. From what I understand, Tomcat and IIS cannot use the same port simultaneously. Therefore I need a way to redirect users. If a user goes to www.example.com then I need them to use http://localhost:80 but if they go to www.otherExample.com then I need them to use http://localhost:8084/otherExample
How does this generally get done?
Set IIS to port 80.
Create two virtual hosts on IIS for your two domains.
Set the document root of the first to a directory on your IIS.
Remove the coyote http/1 connector from Tomcat.
Look here, how to redirect from your IIS to Tomcat.
Map the second virtual host to Tomcat according to the tutorial.
Then you can access example.com and otherExample.com without ports or directory changes.
Well, you should go with something like this:
First of all, I will assume that you know how to map example.com and otherexample.com to 127.0.0.1 and that is really what you want. So I will skip that part and go straight to configuration.
First of all, when users type http://www.domain.com it is EXACTLY THE SAME as typing http://www.domain.com:80. Also, when users type https://www.domain.com it is EXACTLY THE SAME as typing https://www.domain.com:443. That means, if you omit the ports for https and https, 80 and 443 are assumed respectively.
So, this brings you to only one conclusion. You have to set one web server (IIS or Tomcat) to port 80, and another to port 8084. You decide which is which, because for configuration it is irrelevant.
Now, to accomplish what you need, you need to create a redirection script on the server which listens to port 80. So, if you use PHP for redirection script, you could use something like this:
<?php
if ($_SERVER['HTTP_HOST']=='www.otherexample.com') {
Header('Location: http://localhost:8084/otherExample');
}
?>
Also, you could accomplish something similar using configuration file of the server itself (the one that is listening on port 80).
This is only general explanation of the steps you need to take. Obviously, you will need to adapt them to work for your case.
Let me know what you think.

Recaptcha IP addresses

Okay, so we implement Recaptcha in production. We get errors because it can't reach the IP address it needs to use the service. We open a port for the IP address to reach Google. No problem. We do that and configure that IP address explicitly to work. It works great. Then, the next day, we start getting errors again because Recaptcha is using a different IP address. I can allow requests from that IP address, too, but now I'm unsettled. Where are these addresses coming from? How do I configure this to work reliably?
Recatpcha from Google can use any Google IP address and there are lots of them.
Ran this from Windows:
_netblocks.google.com text =
nslookup -type=TXT _netblocks.google.com
"v=spf1 ip4:216.239.32.0/19 ip4:64.233.160.0/19 ip4:66.249.80.0/20 ip4:72.14.192.0/18 ip4:209.85.128.0/17 ip4:66.102.0.0/20 ip4:74.125.0.0/16 ip4:64.18.0.0/20 ip4:207.126.144.0/20 ip4:173.194.0.0/16 ?all"
That's all the network Google uses currently. These can change so check them often.
Google suggest allowing port 80 to all IPs outbound, this highly insecure. They recommend going through a proxy server but again that is highly insecure if your web server is an DMZ. Proxy aware trojans do exist. All that need to be done is exploit a vulnerability to execute arbitrary code and you can create reverse connection on port 80 through a proxy server to download the payload. Then it is trivial to escalate privileges and own the box. I don't mean just Windows servers but Linux as well. I've done it in lab environment on security was on. It's really easy to do.
This is the Google website I got this from:
http://code.google.com/p/recaptcha/wiki/FirewallsAndRecaptcha
I wanted to append to this answer with more recent information. The documentation that Chris is pointing to does not include all of the TXT records necessary to dig (thanks Google):
_netblocks2.google.com (IPv6 subnets)
_netblocks3.google.com (Additional IPv4 subnets)
In my particular case, the _netblocks3 entry contained 2 large /19's that made my initial rule ineffective
(I found additional references here: https://support.google.com/a/answer/60764?hl=en)
Perhaps you should be using a hostname rather than IP

WampServer Hosting

about 6 months ago I got into coding, and I've always wanted to start my own game just for fun on the side.
I have wampserver on my computer, and was wondering if that server could publicly host things on the internet?
You need to:
Make sure your server is available on the internet. If you have a router or firewall you may need to open it up.
If you want to have a domain name you need to register that.
If your ISP can give you a static IP address then ask for that.
Whether you have a static IP or a dynamic one then you can use a service such as DynDNS to link the domain name to the IP address.
Yes, you can use your WAMPserver to allow people to publicly access your site.
From some quick googling, I didn't find any instructions, just that it was possible.
I just put a wamp server up on a box in my house just for funsies.
Here is a wampserver forum post with links to the info you seek.
Here is the basic rundown though:
Open up your router to port 80 and forward it to the box you are serving on.
Get setup on a DNS server, I used freedns.afraid.org.
In wamp you are gonna set apache to use virtual hosts (this is in the link).
After that you should be cool.

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.

Resources