1

I'm working with a home server and my ISP blocks port 80. I have DD-WRT set up on my router so that I can redirect other open ports (like 443 and 8080) to the server. I also have dynamic DNS set up on an automatically updating A record via NameCheap.

My end goal is this: a user goes to http:/dev.homeserver.com and automatically gets https://dev.homeserver.com with no custom ports in the address bar. I want to autoredirect to https because I feel encryption is important and https should be everywhere. Furthermore, I'd like to be able to redirect http:/homeserver.com to https://homeserver.com and all requests such as http:/homserver.com/blah/this/index.php? to be auto redirected to https://homserver.com/blah/this/index.php?, etc.

The problem is that in order for me to send users to the server via our domain (say, dev.homeserver.com), I need to redirect them to a port other than 80 to get to the server. Right now I'm doing this via a name cheap URL redirect that takes host dev and redirects it to http:/dev.homeserver.com:8080. This works, but the problem is the port shows up in the URL, which I'd like to avoid. I can enable URL masking, but then the address bar always says dev.homeserver.com and that can be annoying since myself and my colleagues are usually copying out of the addy bar when testing PHP and coding.

I see no-ip has a way of doing this with what they call a Port 80 Redirect: but it just looks like it forwards to an IP and loses the dns name in the address bar as soon as the site responds.

I also have a VPS with port 80 open and have read a bit on ProxyPass but I want to avoid creating dependencies between the home server and VPS. Still, I'd like to hear if this could be an option if it's the only way forward.

(had to get rid of one / in links since it won't let me post urls with my current reputation)

  • If you are pointing your DNS to your home server and your ISP blocks port 80, there is nothing you can do to get the site working as you want. You will HAVE to point your domain elsewhere. – Stephen Ostermiller Oct 10 '16 at 22:47
2

If you use Cloudflare, their Page Rules will allow you to set up redirects like this. Make sure to set SSL to "Full" under the Crypto tab so it connects to your server over HTTPS as well.

Cloudflare, their [Page Rules

You'll need to use their DNS, but it makes handling this sort of thing a lot easier. Plus it alleviates stress on your home server.

  • Hey, the option just randomly showed up just now! I'll give it a shot and report back – montag Oct 10 '16 at 23:03
  • That doesn't seem to work. It will redirect pages from http:// to https://, no problem (which is great) but it tries to talk to my home server from port 80 on the A record I have specified (not 443, even after a redirect) which doesn't work. If I point it to my VPS it works great. Situation: lowendtalk.com/discussion/50106/… If you know how to get around this, let me know. Until then I'm going to work on setting up a reverse proxy on the VPS. – montag Oct 11 '16 at 4:36
  • Updated the answer to include the crypto requirement. Does that help? – Andrew Lott Oct 12 '16 at 20:56
  • No, sorry. I'm still stuck in the water with my earlier comment. To the best of my knowledge there's no solution using CloudFlare that can address this, which is my root problem. I am seeing if a reverse proxy via the VPS will do it. – montag Oct 13 '16 at 0:00
  • Just an update -- I checked again today; still seems to have the same design flaw with cloud flare. I get 502 bad gateway when using it. If I point it to my vps (port 80 open) it works fine. So I know it's not something I'm doing. – montag Aug 21 '17 at 4:32
1

Actually this was definitely possible (and totally free) with a lot of hacking, and trial and error. I did stand up a reverse proxy on a VPS, which worked well, but I still didn't like the dependency it created on the VPS having to be up (since the two servers I have are totally doing unrelated things).

I initially tried CloudFlare and its advanced url rewriting engine, and it was able to rewrite url requests from 80 ()http) to 443 (HTTPS). The problem is that it tries to communicate with the A record on port 80 (see https://www.lowendtalk.com/discussion/50106/cloudflare-proxy-origin-other-than-port-80). Also, the free version of CloudFlare only grants you five total advanced dns options. I have about 8 subdomains, so this wouldn't work either.

I happened to be fiddling with my Namecheap domain and realized the DNS settings offer a URL rewrite, so I tried redirecting sub.example.com to https://sub.example.com. I didn't get an error message instantly, which happened with dynu.com and afraid.com. Those won't let you save this config. In fact, afraid tells you that it is not possible because it would create an "infinite loop", which is true to some extent because the A record (or CNAME record) is technically ambigious to the url to be rewritten.

Something with Namecheap (the special A+ dynamic record, maybe?) allows you to do this kind of redirect. I couldn't find anything in their docs that mentions this. The interesting thing is that a traceroute to your dns record gets you nowhere, and if you ping your dns name, it doesn't give you your server ip, but instead a Namecheap server ip, so I think it must be some sort of reverse proxy setup on their end. Keep this in mind if you're going to do something like WoL (you'll need a separate A record). So far I haven't ran into any issues.

Anyway, Namecheap offers free DNS management services, so I grabbed that and set up DNS-O-MATIC and had a perfectly working site hosted at home. Now anytime a visitor attempts to go to http:/sub.example.com/xyz they're always redirected to https:/sub.example.com/xyz totally seamlessly and without any port garbage in the url. The ports seem minor but if I give someone a link verbally, it's a lot easier.

Hoping this saves someone else from spending as much time as I did on it.

UPDATE:

The namecheap solution no longer works. I believe they applied a patch or altered the rewrite rules within the last six months which no longer allow for this configuration due to A record/URL rewrite conflicts like other DNS providers. I've abandoned hope--at this time there's no free solution out there without implementing a reverse proxy, or until CloudFlare allows you to specify a port other than 80.

If anyone knows an advanced DNS provider that can do what namecheap used to do, please let me know.

For anyone interested, there's an interesting article on how to create a reverse proxy for free using an Azure Web Apps free trial but it appears there's a 165 MB quota per day. Still though for most people this would work. The link to this article is in my below comment since I don't have enough reputation to post.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.