Category Archives: nginx

NGINX Permission denied in error.log

Looking at the webervers error logs, i´ve found a lot of entries in one of them in an ISPConfig 3 environment:

[crit] 26595#0: *28425 open() "/var/www/site/web/" failed (13: Permission denied), client: xx.xx.xx.xx, server: host.tld, request: "GET / HTTP/1.1", host: "www.host.tld"

I spent some minutes to figure it out. In my case it was a permission error on website root folder (permissions were set to 711).

A simple command “chmod 751 web” fixes my problem.

See also: http://nicholasorr.com/blog/2008/07/22/nginx-engine-x-what-a-pain-in-the-bum/

Using Maxmind´s GeoIP with Nginx for Piwik or other Scripts

Since Piwik 1.9 it´s possible to determine location of visitor IP’s with Maxmind´s GeoIP Databases.  More

If you are using nginx, follow this tutorials:
– Using GeoIP With Nginx On Debian Squeeze/Ubuntu 11.04
– How do I install the GeoIP module for Nginx? (Piwik FAQ #166)

See result: http://seo-quick.info

GeoIP Databases cron update:

#!/bin/bash
cd /etc/nginx/geoip
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz
gunzip -f GeoIP.dat.gz
wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz
gunzip -f GeoLiteCity.dat.gz

Remove PHP X-Powered-By & Nginx Server Details from HTTP Response Header

To remove Server details from Response Header for e.g. security reasons, like

Server nginx/1.2.4
X-Powered-By PHP/5.3.17-1~dotdeb.0

it´s necessary to edit php.ini & nginx.conf as follows.

PHP:
To remove X-Powered-By completely, expose_php should be disabled in php.ini.
...
expose_php = Off
...


Nginx:

To remove Server Version from Header, server_tokens should be disabled in nginx.conf.
...
server_tokens off;
...

See also:
http://wiki.nginx.org/HttpCoreModule#server_tokens
http://forum.nginx.org/read.php?11,1646
http://wiki.nginx.org/NginxHttpHeadersMoreModule


concrete5 nginx configuration

Error:
“Concrete cannot parse the PATH_INFO or ORIG_PATH_INFO information provided by your server.”

Solution:

    location / {
      try_files $uri $uri/ /index.php/$request_uri;
    }

	location ~ \.php($|/) {
		set $script $uri;
		if ($uri ~ "^(.+\.php)(/.+)") {
			set $script $1;
		}
		include /etc/nginx/fastcgi_params;
		fastcgi_pass IP:Port;
		#fastcgi_index index.php;
		fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
		fastcgi_param PATH_INFO $fastcgi_script_name;
		fastcgi_param  URI $uri;
		fastcgi_intercept_errors on;
	}

http://blog.walterebert.com/using-prtty-urls-in-concrete5-with-nginx

nginx: bind() to 123.123.123.123:80 failed (99: Cannot assign requested address)

Following error occurs on nginx restart, if the A Record of a Domain (sites-enabled) points to another IP as nginx is running on.

Nginx Host IP: 231.231.231.231
Domain IP (A Record) changed to: 123.123.123.123

nginx configtest (see nginx documentation / full command depends on host os)

Throws:

Testing nginx configuration: the configuration file /etc/nginx/nginx.conf syntax is
ok[emerg]: bind() to 123.123.123.123:80 failed (99: Cannot assign requested address)
configuration file /etc/nginx/nginx.conf test failed

Solution:

Remove linked Host Configuration File for related Domain and start nginx as usual.