Help with NGINX config for Magento

AMP Admin admin at ampprod.com
Sat Mar 20 18:39:17 MSK 2010


       location / {
                root  /home/path/public_html/store; # absolute path doc root
                index index.php index.html index.htm;

                # this serves static files that exist without running other
rewrite tests
                if (-f $request_filename) {
                        expires 30d;
                        break;
                }

                # this sends all non-existing file or directory requests to
index.php
                if (!-e $request_filename) {
                        rewrite ^(.+)$ /index.php last;
                }
        }

        location ~* \.(jpg|jpeg|gif|css|png|js|ico)$ {
                access_log                      off;
                expires                         30d;
                break;
        }

        location ~ /(admin/).* {
                fastcgi_index           index.php;
                fastcgi_pass            127.0.0.1:9000;
                include                 fastcgi_params;
                auth_basic              "Restricted";
                auth_basic_user_file    /etc/nginx/htpasswd;
                fastcgi_intercept_errors        On;
                fastcgi_ignore_client_abort     On;
                fastcgi_buffer_size             128k;
                fastcgi_param   HTTPS           on;
                fastcgi_buffers                 4 128k;
                root  /home/path/public_html/store; # absolute path doc root
                index index.php index.html index.htm;

                # this serves static files that exist without running other
rewrite tests
                if (-f $request_filename) {
                        expires 30d;
                        break;
                }

                # this sends all non-existing file or directory requests to
index.php
                if (!-e $request_filename) {
                        rewrite ^(.+)$ /index.php?q=$1 last;
                }
        }

        location ~ /(var/|report/|pkginfo/|lib/|includes/|Maged/|app/).* {
                deny    all;
        }

        location ~ \.php$ {
                fastcgi_index                   index.php;
                fastcgi_pass                    127.0.0.1:9000;
                include                         fastcgi_params;
                fastcgi_intercept_errors        On;
                fastcgi_param   HTTPS   on;
                fastcgi_ignore_client_abort     On;
                fastcgi_buffer_size             128k;
                fastcgi_buffers                 4 128k;
        }


        ### EXTRA SECURITY ###
        ## Only allow GET, POST and HEAD request methods
        if ($request_method !~ ^(POST|GET|HEAD)$ ) {
                return 444;
        }

        # deny access to .htaccess files, if Apache's document root
        location ~ /\.ht {
            deny  all;
        }


Regards, 

-Team AMP 
http://www.globalamp.com 
http://mp3-remix.com

-----Original Message-----
From: Howard Barntt [mailto:lists at ruby-forum.com] 
Sent: Saturday, March 20, 2010 2:37 AM
To: nginx at nginx.org
Subject: Help with NGINX config for Magento

Hi,

I have seen a similar situation here but the solution didn't work for
me. I am getting a 'NO INPUT FILE SPECIFIED' and my permanent redirect
from non-www to www doesn't seem to work.

Here is my conf file at /etc/nginx/nginx.conf

user       nginx nginx;
worker_processes  6;

error_log       /var/log/nginx/error.log;
pid                     /var/run/nginx.pid;

events {
        worker_connections  1024;
}

http {
       include                     /etc/nginx/mime.types;
       default_type          application/octet-stream;

       log_format main '$remote_addr - $remote_user [$time_local]
$request '
                                   '"$status"
$body_bytes_sent"$http_referer" '
                                   '"$http_user_agent"
"$http_x_forwarded_for"';

       access_log            /var/log/nginx/access.log  main;
       sendfile              on;
       tcp_nopush            on;
       tcp_nodelay          off;
       gzip                  on;
       gzip_http_version    1.0;
       gzip_comp_level       2;
       gzip_proxied              any;
       gzip_types   text/plain text/css application/x-javascript
text/xml application/xml application/xml+rss text/javascript

       # fastcgi nodes
       upstream backend {
              server unix:/tmp/fcgi.sock;
       }

       server {
       listen                     80;
       server_name     www.openfreeze.com;
       root                      /var/www/html;
       client_max_body_size       50M;
       # protection (we have no .htaccess)
       location ~
(^/magento/(app/|includes/|lib/|/pkginfo/|var/|report/config.xml)|/\.svn/|/.
hta.+)
{
              deny all;
       }

       # vhost specific access log
       access_log    /var/log/nginx/vhost.access.log    main;

       # this rewrites all the requests to the maintenance.html
       if (-f $document_root/system/maintenance.html) {
              rewrite    ^(.*)$    /system/maintenance.html last;
              break;
       }

       # handle all .php files, /downloader and /report
       location ~ (\.php|/downloader/?|/report/?)$ {
              if ($request_uri ~ /(downloader|report)$){
                     # no trailing /, redirecting
                     rewrite  ^(.*)$ $1/ permanent;

        }

        fastcgi_index index.php;
       include /etc/nginx/fastcgi_params;
       fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;

       if (-e $request_filename) { # check if requested path exists
       fastcgi_pass backend;
       }

       }

       # magento
       location / {
              # set expire headers
              if ($request_uri ~* "\.(ico|css|js|gif|jpe?g|png)$") {
                     expires max;
              }

       # set fastcgi settings, not allowed in the .if. block
       include /etc/nginx/fastcgi_params;
       fastcgi_param SCRIPT_FILENAME $document_root/index.php;
       fastcgi_param SCRIPT_NAME /index.php;

       # rewrite - if file not found, pass it to the backend
       if (!-f $request_filename) {
              fastcgi_pass backend;
              break;
       }
       }
}
}


HERE IS MY FASTCGI_PARAMS /etc/nginx/fastcgi_params

fastcgi_param  QUERY_STRING       $query_string;
fastcgi_param  REQUEST_METHOD     $request_method;
fastcgi_param  CONTENT_TYPE       $content_type;
fastcgi_param  CONTENT_LENGTH     $content_length;

fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
fastcgi_param  REQUEST_URI        $request_uri;
fastcgi_param  DOCUMENT_URI       $document_uri;
fastcgi_param  DOCUMENT_ROOT      $document_root;
fastcgi_param  SERVER_PROTOCOL    $server_protocol;

fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;

fastcgi_param  REMOTE_ADDR        $remote_addr;
fastcgi_param  REMOTE_PORT        $remote_port;
fastcgi_param  SERVER_ADDR        $server_addr;
fastcgi_param  SERVER_PORT        $server_port;
fastcgi_param  SERVER_NAME        $server_name;

# PHP only, required if PHP was built with --enable-force-cgi-redirect
fastcgi_param  REDIRECT_STATUS    200;

Any help will be really appreciated.
-- 
Posted via http://www.ruby-forum.com/.

_______________________________________________
nginx mailing list
nginx at nginx.org
http://nginx.org/mailman/listinfo/nginx




More information about the nginx mailing list