Conversion of PHP single machine setup to nginx/php residing on different boxes

Johannes Graumann johannes_graumann at web.de
Wed Jun 6 13:18:10 UTC 2012


Hello,

I am trying to implement http://www.howtoforge.com/installing-nginx-with-
php5-and-mysql-support-on-debian-squeeze , where the nginx server config 
looks like so:

> server {
>         listen   80; ## listen for ipv4
>         listen   [::]:80 default ipv6only=on; ## listen for ipv6
>         server_name  _;
>         access_log  /var/log/nginx/localhost.access.log;
>         location / {
>                 root   /var/www;
>                 index  index.php index.html index.htm;
>         }
>         location /doc {
>                 root   /usr/share;
>                 autoindex on;
>                 allow 127.0.0.1;
>                 deny all;
>         }
>         location /images {
>                 root   /usr/share;
>                 autoindex on;
>         }
>         #error_page  404  /404.html;
>         # redirect server error pages to the static page /50x.html
>         #
>         #error_page   500 502 503 504  /50x.html;
>         #location = /50x.html {
>         #       root   /var/www/nginx-default;
>         #}
>         # proxy the PHP scripts to Apache listening on 127.0.0.1:80
>         #
>         #location ~ \.php$ {
>                 #proxy_pass   http://127.0.0.1;
>         #}
>         # pass the PHP scripts to FastCGI server listening on 
127.0.0.1:9000
>         #
>         location ~ \.php$ {
>                 try_files $uri =404;
>                 fastcgi_pass   127.0.0.1:9000;
>                 fastcgi_index  index.php;
>                 fastcgi_param  SCRIPT_FILENAME 
/var/www$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;
>         }
> }

My setup looks slightly different from the one used for that howto, as I 
have a host/firewall/nginx box that houses client applications in lxc-
containers. I am having trouble in setting up the ~ \.php$ bit in that 
context. My config lookis like this:

> server {
>         listen   443;
>         server_name  XXX;
>         client_max_body_size 40M;
>         # SSL is using CACert credentials
>         ssl  on;
>         ssl_certificate  /etc/ssl/private/cacert.XXX.org.pem;
>         ssl_certificate_key  
/etc/ssl/private/cacert.XXX.org_privatkey.pem;
>         ssl_session_timeout  5m;
>         ssl_protocols  SSLv3 TLSv1;
>         ssl_ciphers  ALL:!ADH:!EXPORT56:!LOW:RC4+RSA:+HIGH:+MEDIUM:+SSLv3:
+EXP;
>         ssl_prefer_server_ciphers   on;
>         # Proxy the "feng-container" lxc container
>         location / {
>                 proxy_pass http://10.10.10.3:80/;
>         }
>         location ~ \.php$ {
>                 try_files $uri =404;
>                 fastcgi_pass   10.10.10.3:9000;
>                 fastcgi_index  index.php;
>                 fastcgi_param  SCRIPT_FILENAME  
http://10.10.10.3:80/$fastcgi_script_name;
>                 include         fastcgi_params;
>         }
> }

The "/" bit works, but php location gives me "404" despite ports 80/9000 
being open ...

Can anyone nudge me into the right direction on how to proceed here?

Thanks, Joh




More information about the nginx mailing list