Question
Moved DynDNS Service from Apache to nginx
Hi,
i just moved my dyndns service from my apache2 server to my new nginx machine.
While the service was working good on apache it didn´t on nginx.
The Fritzbox connects to my dyndns service via this link
http://dyn.myserver.co/myscript.php?pass=mypassword&meineip=<ipaddr>
Thats the script (myscript.php)
$pwort = 'mypassword';
$port = ':80';
$dyntxt = "my_IP.txt";
$pworttest = $_GET["pass"];
$IP = $_GET["meineip"];
if (file_exists($dyntxt)){if($pworttest==$pwort) { $a = fopen("$dyntxt", "w");
$dynamicip = $_SERVER["REMOTE_ADDR"];
fwrite($a, $IP);
fclose($a); }
else { $a = fopen("$dyntxt", "r+");
$dynamicip = fread($a,filesize($dyntxt));
fclose($a);
$url="http://".$dynamicip."".$port;
header("Location: $url");} }
?>
And here is my config for dyn.myserver.co on nginx:
server {
listen 80;
listen [::]:80;
root /var/www/dyn;
index index.php index.html index.htm;
server_name dyn.myserver.co;
location / {
try_files $uri/ /index.php?$args;
}
error_page 404 /404.html;
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /var/www/dyn;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
}
}
The IP which is written in myIP.txt is copied to the DNS Server by cronjob. That is working.
For example: On my apache server i called the dyndns URL (http://dyn.myserver.co/myscript.php) and was redirected to the IP which was filled in myIP.txt. On nginx it just shows me the content of myscript.php.
I think it´s a problem with the nginx config. Can anybody help me?
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
×