[Help] nginx settings
August 05, 2012 08:25AM
Hello, i'm new with nginx and i need a little help. I used apache and i want to switch to nginx. I manage a free images hosting.

I installed nginx and php-fpm. I started both service, "service php-fpm start" and "service nginx stop".

I setup the nginx like that:

[code]
server {
server_name www.example.com example.com;
root /home/admin/example.com/;

listen 80;
if ($host = 'www.example.org' ) {
rewrite ^/(.*)$ http://example.org/$1 permanent;
}

location / {
if (-f $request_filename/index.html){
rewrite (.*) $1/index.html break;
}
if (-f $request_filename/index.php){
rewrite (.*) $1/index.php;
}
if (!-f $request_filename){
rewrite (.*) /index.php;
}
try_files $uri $uri/ /api.php;
}

location /admin {
try_files $uri /admin/index.php?$args;
}

location ~ \.php$ {
fastcgi_pass 127.0.0.1:9000;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME /usr/share/nginx/html$fastcgi_script_name;
include fastcgi_params;
}

location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
{
expires 8d;
}

location ~ .*\.(js|css)?$
{
expires 8d;
}
}
[/code]

The problem is that if i connect to my website appear "File not found. "

On nginx log appear:

[code]
2012/08/05 14:13:46 [crit] 4108#0: *8 stat() "/home/admin/example.com/favicon.ico" failed (13: Permission denied), client: 10.10.51.1, server: www.example.com, request: "GET /favicon.ico HTTP/1.0", host: "example.com"

2012/08/05 14:13:46 [error] 4108#0: *8 FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream, client: 10.10.51.1, server: www.example.com, request: "GET /favicon.ico HTTP/1.0", upstream: "fastcgi://127.0.0.1:9000", host: "example.com"
[/code]

About first message i recive a lot of it.

Thank you for help,
Cheers
Re: [Help] nginx settings
August 05, 2012 08:38AM
First error solved, one folder had privileges wrong.

I have always the second error:
FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream

And always the error "File not found."
Re: [Help] nginx settings
August 05, 2012 09:38AM
I'm running now the site with ngnix and seems to be better, i mean that there isn't crash. But always very very slow site. How i disable Cloudflare after 1 minute the site start to become very slow like 1 minute to load the page.

I have 18.000.000 hits every day.

MY QUESTION;
There is the possibility to block the bandwitdh (load) for an images that for example overcome 200 request in a minute?

Because some images are posted on popular site like Facebook, and i want that only first 200 users can see the image, the others must wait some times to see it.

This i think can save some bandwitdh and server load.

Thank you for help.



Edited 1 time(s). Last edit at 08/05/2012 09:38AM by shayol.
Re: [Help] nginx settings
August 05, 2012 05:02PM
I fixed all, i need another help. This redirect on my

RewriteRule ^images/(\w*\.)(jpg|png|gif)$ images/old/$1$2 [L] #legacy images

From:
http://www.example.com/images/ArHVY.jpg
To:
http://www.example.com/images/old/ArHVY.jpg
Re: [Help] nginx settings
August 22, 2012 03:30PM
shayol Wrote:
-------------------------------------------------------
> First error solved, one folder had privileges wrong.
>
> I have always the second error:
> FastCGI sent in stderr: "Primary script unknown" while reading
> response header from upstream
>
> And always the error "File not found."

Hi:

How did you fix this error "FastCGI sent in stderr: "Primary script unknown" while reading response header from upstream" ?

Thanks
Re: [Help] nginx settings
August 25, 2012 11:24AM
daav76 Wrote:
-------------------------------------------------------
> shayol Wrote:
> -------------------------------------------------------
> > First error solved, one folder had privileges wrong.
> >
> > I have always the second error:
> > FastCGI sent in stderr: "Primary script unknown" while reading
> > response header from upstream
> >
> > And always the error "File not found."
>
> Hi:
>
> How did you fix this error "FastCGI sent in stderr: "Primary script
> unknown" while reading response header from upstream" ?
>
> Thanks

Hello, sincerly i don't remember. But the problem was or bad configuration of nginx or problem with php-fpm.
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 148
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 500 on July 15, 2024
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready