3.7 Using a PHP gateway to access your site
The problem with using this setup is that your website's port will change periodically. To combat this problem, I've written a PHP script for Era's website which allows you to visit
http://graalcenter.org/ and be redirected to the current site. It also redirects requests for specific pages, so that you can link to
http://graalcenter.org/some/random/page and know that it will always work.
The PHP code I used for this PHP gateway is:
index.php
PHP Code:
<?php
$fh = fopen("port.txt", "r");
$port = fread($fh, filesize("port.txt"));
fclose($fh);
header("Location: http://server.era.graalcenter.org:" . $port . "/" . $_GET['go']);
?>
update.php
PHP Code:
<?php
$pass = "change_me";
$ip = "50.23.136.183"; // get this from statistics.graal.us
if ($_SERVER['REMOTE_ADDR'] != $ip || $_GET['pass'] != $pass) {
die("**** off");
}
$fh = fopen("port.txt", "w") or die("aa");
fwrite($fh, $_GET['port']) or die("bb");
fclose($fh);
?>
.htaccess
Quote:
RewriteEngine On
RewriteCond %{SCRIPT_FILENAME} !-f
RewriteCond %{SCRIPT_FILENAME} !-d
RewriteRule ^(.*)$ index.php?go=$1 [QSA,L]
|
Be sure to change the password and the redirect URL. You can then enable it in
http_listensocket.
4. Conclusion
I think I've covered everything. The script is attached as a ZIP file to the post above. If you have any questions, feel free to ask. Comments are also welcome.
You can see an example of Grattpd in action at
http://graalcenter.org/ (note that the site is unfinished).