https://github.com/burchill/redirect_repo
A cheap way of redirecting to a local IP
https://github.com/burchill/redirect_repo
Last synced: 4 months ago
JSON representation
A cheap way of redirecting to a local IP
- Host: GitHub
- URL: https://github.com/burchill/redirect_repo
- Owner: burchill
- Created: 2019-09-06T19:08:39.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2023-06-19T22:10:04.000Z (almost 2 years ago)
- Last Synced: 2024-08-13T07:03:10.658Z (8 months ago)
- Language: HTML
- Homepage:
- Size: 16.6 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- jimsghstars - burchill/redirect_repo - A cheap way of redirecting to a local IP (HTML)
README
# redirect_repo
## A cheap way of redirecting to a local IPI have a RaspberryPi Flask website running on my local network. Instead of remembering the Pi's IP address or configuring my DNS, etc., I have come up with this system, which redirects a public URL to my private local site. I do this via the following.
First, I have a domain name that refers to my GitHub Pages site (zachburchill.ml --> burchill.github.io), using the normal CNAME method.
Then, I added an additional CNAME record to the registrar's account, for the subdomain `scale.zachburchill.ml` (named that because my local site is built around tracking my weight).Now my registrar's record table looks like this:
| Name | Type | TTL | Target |
--------|-------|------|----------|
| | A | 14440| 192.30.252.153 |
| | A | 14440| 192.30.252.154 |
| WWW | CNAME | 14440 | burchill.github.io |
| SCALE | CNAME | 3600 | burchill.github.io |Then I added the `CNAME` file to this directory and included the `index.html` file that automatically redirects the browser to the local site.
This worked well, but I realized I couldn't do something like `http://scale.zachburchill.ml/weight_tracker/` and have it redirect to `http:///weight_tracker/` since the `weight_tracker` page doesn't exist as a page in this public repo. I came up with a clever (in my opinion) workaround: since non-existent page requests are (generally) redirected to the `/404.html/` page, I could make a 404 page that would get the URL the user was *attempting* to visit and redirect them to that page on the local site (via Javascript).
With that, I can type `scale.zachburchill.ml/weight_tracker/` and have it directed to `http:///weight_tracker/` automatically.