views:

560

answers:

7

I currently use my local web server to allow costumers to preview some applications and also to allow downloads of "nightly builds" of my open source library.

Problem is I changed my ISP and now my port 80 is blocked.

Altough I know I could easily change the port on the Apache server, I'd like to avoid that unless there's no alternative.

Do you know any third party service (free or paid) that would do a port forward to my website, making it transparent to someone accessing it?

One other idea I heard about was using mod rewrite from my current webhost to rewrite to my domain, but I'd also prefer not go this path. Besides that, do you know any .htaccess examples that actually work? I have tried this:

RewriteEngine on
RewriteRule ^/(.*) http://www.example.com:8080/$1

But it doesn't seem to be working.

Thanks in advance for any ideas.

A: 

I think most DynamicDNS services allow port-forwarding.

Asaf R
They provide URL forwarding, right? They forward http://www.xyz.com to http://www.abc.com:8080/ but it seems that other cases are not supported like http://www.xyz.com/app1/abc.py for instance. Also, if the por 8080 is blocked on the costumer, you're out of luck, right?
kolrie
A: 

Ask your ISP why this is, and if you don't get an answer, switch ISPs again.

Rolf
Unfortunately that's not an alternative. I live in Brazil and there are two broadband providers that covers my region: the one I was using before, which is very expensive and 2Mb downlink and 150kbps uplink. This new one have 6Mb down 600kbps up and I cannot break the contract now :(
kolrie
+1  A: 

Hi, With port 80 being blocked, routing through Dynamic Service win't help, unless the client specifies the new port in the domain.

Have your local router "port-forward" traffic from a new port (say 8080) to port 80. Leave everything the same on your end.

Create an account with DynDNS.org and set up your dynamic service. Then have your client do http://mydomain.com:8080

That should do the trick

Still look into Rolf's suggestion as they are not real ISP,....seriously.

Thanks

Saif Khan
+1  A: 

If you can't get your ISP to open up port 80 for you, and you can't switch ISPs, then use the htacccess redirect directive:

Redirect 301 / http://yourserver.com:8000/

The users may notice the redirect, but they probably won't care.

Jesse Weigert
+2  A: 

Hi, "and back again to the costumer on a transparent way"....will be taken care of by NAT so that shouldn't be a problem.

To handle the request translation from one string to another, well that's an issue since you need to transform the request before it hits the server. Look into some kind of URL forwarding service

http://www.dnsexit.com/Direct.sv?cmd=webforward

Also you can setup a separate site on a provider server and have it forward requests to the specific address/link on your server.

Hope this helps!

Saif Khan
NAT (I guess you mean on his home router) only affects IPs in TCP/IP, it won't penetrate the HTTP layer and change the port back to :80 or URLs back to myaddress.com. NAT doesn't know about the forward, it only sees incoming TCP:8080 traffic. "Back again transparently" requires a custom HTTP proxy.
joelhardi
That's what I meant. He needn't worry about the response being returned....you are correct about the HTTP Proxy.
Saif Khan
+1  A: 

What I'd like is for the costumer to type http://myaddress.com/hello/there?a=1&b=2 and it get translated to http://mylocalserver.com:8080/hello/there?a=1&b=2 and back again to the costumer on a transparent way.

I believe this is the Apache RewriteRule you're looking for to redirect any URL:

RewriteRule ^(.*)$ http://mylocalserver.com:8080$1 [R]

From then on the customer will be browsing mylocalserver.com:8080 and that's what they'll see in the address bar. If what you mean by "and back again" is that they still think they're browsing myaddress.com, then what you're talking about is a rewriting proxy server.

By this, I mean you would have to rewrite all URLs not only in HTTP headers but in your HTML content as well (i.e. do a regex search/replace on the HTML), and decode, rewrite and resend all GET, POST, PUT data, too. I once wrote such a proxy, and let me tell you it's not a trivial exercise, although the principle may seem simple.

I would say, just be happy if you can get the redirect to work and let them browse mylocalserver.com:8080 from that point on.

joelhardi
+1  A: 

Well, even though I appreciated the answers, I wasn't quite satisfied with the final result. I wanted my ISP changes to be transparent to my costumers and I think I managed to make it work.

Here's what I did:

I hired a cheap VPS server - VPSLink - and chose its cheapest plan: 64Mb RAM, 2Gb HD and 1Gb monthly traffic. After a lifetime 10% discount it was only US$ 7.16 per month, pretty affordable for the job and you get a sandbox VPS server as a bonus. The hosting seems so far so good - no problems. If you want to give it a shot you can either signup from its site, indicated above or through a referral code. There are a bunch available on the internet, you just need to search. Also, I can easily create one for you if you want, just leave a comment on this answer: you'll get 10% off and I a month free. I won't post the directly here because it may seem that was the intention behind this post - which was not.

This account is unmanaged but it provides root access. I then configured apache to act as a Proxy to my port 80 requests, transparently forwarding them to my local website on port 8081.

Below are some snippets of my Apache's httpd.conf config files.

VPS Server configuration:

<VirtualHost *:80>
 ServerName mydomain.com
 ServerAlias www.mydomain.com *.mydomain.com
 RewriteEngine On
 RewriteCond %{HTTP_HOST} (.*)\.mydomain\.com [NC]
 RewriteRule (.*) http://mylocalserverdns.mydomain.com:8081/%1$1 [P]
</VirtualHost>

This makes request like http://subdomain1.mydomain.com/script?a=b to be transparently forwarded on server side to http://mylocalserverdns.mydomain.com:8081/subdomain1/script?a=b, so I can do whatever I want from there.

On my local server, I did the same thing to distribute my subdomains handler. I have, for instance two Java server applications that runs on ports 8088 and 8089 locally. All I had to do was another proxy forward, now internally

Local Server configuration:

<VirtualHost *:8081>
 ServerName mylocalserverdns.mydomain.com

 ProxyPass /app1 http://127.0.0.1:8088
 ProxyPassReverse /app1 http://127.0.0.1:8088
 ProxyPassReverse /app1 http://mylocalserverdns.mydomain.com:8088/app1

 ProxyPass /app2 http://127.0.0.1:8089
 ProxyPassReverse /app2 http://127.0.0.1:8089
 ProxyPassReverse /app2 http://mylocalserverdns.mydomain.com:8089/app2
</VirtualHost>

Hope this is worth if someone else is looking for the same alternative.

kolrie