View Single Post
  #6   (View Single Post)  
Old 23rd December 2012
J65nko J65nko is offline
Administrator
 
Join Date: May 2008
Location: Budel - the Netherlands
Posts: 4,131
Default

I installed the latest OpenBSD amd64 snapshot, nginx and php_fpm from the snapshot packages. The only thing I had to to get DNS lookups working from within php was to create an etc directory and copy /etc/resolv.conf to it:

Code:
root@fidelity[/var/www]cat etc/resolv.conf
                                                                                                                                 
search utp.xnet
nameserver 192.168.222.10
I have to admit that I first forgot to create /var/www/etc. Then it does not work at all. The 'chroot" starts at /var/www so a program looking for "/etc/resolv.conf" really needs that "etc" directory.

I used the following PHP script:
PHP Code:
<html>

<head>
<title>Test for php DNS requests</title>
</head>

<body>
<h1>Testing PHP-FPM with nginx</h1>


<?php
$host 
'www.openbsd.org';

echo 
"<h4>Trying to resolve IP address of $host</h4>";
$ip gethostbyname($host);

echo <<< END_OF_TXT
<p>
IP address of 
$host$ip
</p>  

END_OF_TXT;


echo 
"<p>A reverse lookup of $ip : ";

$name gethostbyaddr($ip);
echo 
$name;
echo 
"</p>";
?>
</body>

</html>
The output;

HTML Code:
:<html>

<head>
<title>Test for php DNS requests</title>
</head>

<body>
<h1>Testing PHP-FPM with nginx</h1>


<h4>Trying to resolve IP address of www.openbsd.org</h4><p>
IP address of www.openbsd.org: 129.128.5.194
</p>  
<p>A reverse lookup of 129.128.5.194 : obsd3.srv.ualberta.ca</p></body>

</html>
The tcpdump output (truncated because the snap length is too short):

Code:
09:03:42.222806 192.168.222.240.41997 > 192.168.222.10.53: 43294+ A? www.openbsd.org. (33)
09:03:42.223868 192.168.222.10.53 > 192.168.222.240.41997: 43294 1/0/0 A 129.128.5.194 (49)
09:03:42.224031 192.168.222.240.1883 > 192.168.222.10.53: 36739+ PTR? 194.5.128.129.in-addr.arpa. (44)
09:03:42.224944 192.168.222.10.53 > 192.168.222.240.1883: 36739 1/0/0 PTR[|domain]
The modification of /etc/nginx.conf:
Code:
root@fidelity[/etc/nginx]diff -u nginx.conf.orig nginx.conf      
--- nginx.conf.orig     Sun Dec 23 07:06:55 2012
+++ nginx.conf  Sun Dec 23 07:32:07 2012
@@ -66,20 +66,21 @@
 
         # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
         #
-        #location ~ \.php$ {
-        #    root           /var/www/htdocs;
-        #    fastcgi_pass   127.0.0.1:9000;
-        #    fastcgi_index  index.php;
-        #    fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
-        #    include        fastcgi_params;
-        #}
+        location ~ \.php$ {
+            #root          /var/www/htdocs;
+            root           /htdocs;
+            fastcgi_pass   127.0.0.1:9000;
+            fastcgi_index  index.php;
+            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
+            include        fastcgi_params;
+        }
 
         # deny access to .htaccess files, if Apache's document root
         # concurs with nginx's one
         #
-        #location ~ /\.ht {
-        #    deny  all;
-        #}
+        location ~ /\.ht {
+            deny  all;
+        }
     }
__________________
You don't need to be a genius to debug a pf.conf firewall ruleset, you just need the guts to run tcpdump
Reply With Quote