HTML as PHP

Hello,

i want html files use as php file. So i have write the follow config:

/etc/nginx/nginx.conf
server {
listen 80;
server_name silviosiefke_de;
access_log /var/www/silviosiefke_de/log/access_log main;
error_log /var/www/silviosiefke_de/log/error_log info;

location / {
root /var/www/silviosiefke_de/htdocs;
index index.html index.htm index.php;
}

#location /article-(\d+).html$ {
#try_files $uri $uri/ /blogdetail.html?id=$1;
#}

pass the PHP scripts to FastCGI

location ~ .(php|htm|html)$ {
#location ~ .php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME
/var/www/silviosiefke_de/htdocs$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}

location ~ /.ht {
deny all;
}
}

When i make restart nginx and go on the side i read only Access denied.
In the log i have:

access.log
192.168.0.22 - - [18/Apr/2012:00:15:54 +0200] “GET /blog/manage.html
HTTP/1.1” 403 25 “-” “Mozilla/5.0 (Macintosh; U; Intel Mac OS X; de-de)
AppleWebKit/535+ (KHTML, like Gecko) Version/5.0 Safari/535.4+
Midori/0.4” “-”

No entrys in the error.log. Has someone an idea?

Regards
Silvio

On Wed, 2012-04-18 at 00:17 +0200, Silvio S. wrote:

location ~ /.ht {
deny all;
}

This also matches .html files. Try making your regex more explicit.

Cliff

Hello,

On Tue, 17 Apr 2012 15:56:34 -0700
Cliff W. [email protected] wrote:

On Wed, 2012-04-18 at 00:17 +0200, Silvio S. wrote:

location ~ /.ht {
deny all;
}

This also matches .html files. Try making your regex more explicit.

ok i have delete the part, but the error is the same. Access Denied.
And in the logs the same message, 403.

Regards
Silvio

On Tue, 2012-04-17 at 15:56 -0700, Cliff W. wrote:

On Wed, 2012-04-18 at 00:17 +0200, Silvio S. wrote:

location ~ /.ht {
deny all;
}

This also matches .html files. Try making your regex more explicit.

My mistake, it doesn’t. Check these:

  1. file/directory permissions are correct
  2. is the php app is setting the status to 403?

Regards,
Cliff

On Wed, 2012-04-18 at 01:02 +0200, [email protected] wrote:

ok i have delete the part, but the error is the same. Access Denied.
And in the logs the same message, 403.

Can you also check the main nginx error log?
Usually /var/log/nginx/error.log.

Cliff

On Tue, 17 Apr 2012 16:12:33 -0700
Cliff W. [email protected] wrote:

Can you also check the main nginx error log?
Usually /var/log/nginx/error.log.

Thats stand in the main error.log

2012/04/18 01:00:08 [info] 6802#0: Using 32768KiB of shared memory for
push module in /etc/nginx/nginx.conf:85
2012/04/18 01:00:08 [notice] 6330#0: signal 15 (SIGTERM) received,
exiting
2012/04/18 01:00:08 [notice] 6332#0: exiting
2012/04/18 01:00:08 [notice] 6332#0: exit
2012/04/18 01:00:08 [notice] 6330#0: signal 17 (SIGCHLD) received
2012/04/18 01:00:08 [notice] 6330#0: worker process 6332 exited with
code 0
2012/04/18 01:00:08 [notice] 6330#0: exit
2012/04/18 01:00:08 [notice] 6817#0: using the “epoll” event method
2012/04/18 01:00:08 [notice] 6817#0: nginx/1.0.15
2012/04/18 01:00:08 [notice] 6817#0: OS: Linux 3.2.14
2012/04/18 01:00:08 [notice] 6817#0: getrlimit(RLIMIT_NOFILE): 1024:4096
2012/04/18 01:00:08 [notice] 6818#0: start worker processes
2012/04/18 01:00:08 [notice] 6818#0: start worker process 6820
2012/04/18 01:12:29 [notice] 6818#0: signal 15 (SIGTERM) received,
exiting
2012/04/18 01:12:29 [notice] 6820#0: exiting
2012/04/18 01:12:29 [notice] 6820#0: exit
2012/04/18 01:12:29 [notice] 6818#0: signal 17 (SIGCHLD) received
2012/04/18 01:12:29 [notice] 6818#0: worker process 6820 exited with
code 0
2012/04/18 01:12:29 [notice] 6818#0: exit
2012/04/18 01:12:32 [info] 7036#0: Using 32768KiB of shared memory for
push module in /etc/nginx/nginx.conf:85
2012/04/18 01:12:32 [notice] 7040#0: using the “epoll” event method
2012/04/18 01:12:32 [notice] 7040#0: nginx/1.0.15
2012/04/18 01:12:32 [notice] 7040#0: OS: Linux 3.2.14
2012/04/18 01:12:32 [notice] 7040#0: getrlimit(RLIMIT_NOFILE): 1024:4096
2012/04/18 01:12:32 [notice] 7041#0: start worker processes
2012/04/18 01:12:32 [notice] 7041#0: start worker process 7043
2012/04/18 01:12:57 [info] 7058#0: Using 32768KiB of shared memory for
push module in /etc/nginx/nginx.conf:85
2012/04/18 01:12:57 [notice] 7041#0: signal 15 (SIGTERM) received,
exiting
2012/04/18 01:12:57 [notice] 7043#0: exiting
2012/04/18 01:12:57 [notice] 7043#0: exit
2012/04/18 01:12:57 [notice] 7041#0: signal 17 (SIGCHLD) received
2012/04/18 01:12:57 [notice] 7041#0: worker process 7043 exited with
code 0
2012/04/18 01:12:57 [notice] 7041#0: exit
2012/04/18 01:12:58 [notice] 7073#0: using the “epoll” event method
2012/04/18 01:12:58 [notice] 7073#0: nginx/1.0.15
2012/04/18 01:12:58 [notice] 7073#0: OS: Linux 3.2.14
2012/04/18 01:12:58 [notice] 7073#0: getrlimit(RLIMIT_NOFILE): 1024:4096
2012/04/18 01:12:58 [notice] 7074#0: start worker processes
2012/04/18 01:12:58 [notice] 7074#0: start worker process 7076

On Tue, 17 Apr 2012 16:10:55 -0700
Cliff W. [email protected] wrote:

  1. file/directory permissions are correct

gentoo-desk htdocs # ls -l
insgesamt 40
drwxr-xr-x 2 siefke siefke 4096 18. Apr 00:08 blog
-rw-r–r-- 1 siefke siefke 1406 18. Mr 2011 favicon.ico
drwxr-xr-x 2 siefke siefke 4096 16. Apr 20:02 howto
drwxr-xr-x 4 siefke siefke 4096 16. Apr 13:38 img
drwxr-xr-x 2 siefke siefke 4096 18. Apr 00:08 inc
-rw-r–r-- 1 siefke siefke 1137 17. Apr 22:45 index.html
-rw-r–r-- 1 siefke siefke 17 14. Apr 00:09 info.php
-rw-r–r-- 1 siefke siefke 43 16. Apr 20:28 robots.txt
-rw-r–r-- 1 siefke siefke 508 16. Apr 20:28 sitemap.xml

  1. is the php app is setting the status to 403?

The mistake come in blog directory, ok i try in root without any
php inside html, but it come too Access denied.

The complete nginx.conf → Loading...
The php-php.conf → Loading...

Thank u for ur Help.

Regards
Silvio

Hello,

when used Nginx with PHP-FPM, should set the follow in your fpm config.

security.limit_extensions = .php .html

Regards
Silvio