Error pages/Web Authentication

HTF nginx-forum at nginx.us
Fri Jun 10 22:13:31 MSD 2011


Could you please have a look on my config files:
---------------------------------------------------------------------------
NGINX.CONF
"user              nginx;
worker_processes  4;

error_log  /var/log/nginx/error.log;
#error_log  /var/log/nginx/error.log  notice;
#error_log  /var/log/nginx/error.log  info;

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;
## Size Limits
  client_body_buffer_size   8k;
  client_header_buffer_size 1k;
  client_max_body_size      100k;
  large_client_header_buffers 1 1k;
## Timeouts 
  client_body_timeout   60;
  client_header_timeout 60;
  keepalive_timeout     60 60;
  send_timeout          60;
## General Options
  ignore_invalid_headers   on;
  limit_zone gulag $binary_remote_addr 1m;
  recursive_error_pages    on;
  sendfile                 on;
  server_name_in_redirect off;
  server_tokens           off;
## TCP options  
  tcp_nodelay on;
  tcp_nopush  on;
## Compression
  gzip              on;
#  gzip_static       on;
  gzip_buffers      16 8k;
  gzip_comp_level   6;
  gzip_http_version 1.0;
  gzip_min_length   0;
  gzip_types        text/plain text/css image/x-icon image/bmp;
  gzip_vary         on;
  gzip_disable "MSIE [1-6].(?!.*SV1)";
    #
    # The default server
    # Load config files from the /etc/nginx/conf.d directory
    include /etc/nginx/conf.d/*.conf;
}"
--------------------------------------------------------------------------------------------
VIRTUAL.CONF
"server {
  listen mydomain.com default_server;

  server_name mydomain.com www.mydomain.com;

  root   /home/web/mydomain.com;
          index index.php index.html index.htm /index.php;

  add_header  Cache-Control public;
  expires     31d;
## Only allow these request methods
      if ($request_method !~ ^(GET|HEAD|POST)$ ) {
         return 444;
      }
## Deny illegal Host headers
      if ($host !~* ^(mydomain.com|www.mydomain.com)$ ) {
        return 444;
      }
## Deny certain User-Agents (case insensitive)
     ## The ~* makes it case insensitive as opposed to just a ~
     if ($http_user_agent ~* (Baiduspider|Jullo) ) {
        return 444;
     }
## Deny certain Referers (case insensitive)
     ## The ~* makes it case insensitive as opposed to just a ~
     if ($http_referer ~*
(babes|click|diamond|forsale|girl|jewelry|love|nudit|organic|poker|porn|poweroversoftware|sex|teen|video|webcam|zippo)
) {
        return 444;
     }
## Redirect from www to non-www
      if ($host = 'www.mydomain.com' ) {
        rewrite  ^/(.*)$  http://domain.com/$1  permanent;
      }
## Serve an empty 1x1 gif _OR_ an error 204 (No Content) for
favicon.ico
      location = /favicon.ico {
       #empty_gif;
        return 204;
      }
  location  / {
            try_files $uri $uri/ /index.php?q=$request_uri;
         }

  location  /administrator  {
  auth_basic            "Authorized Access Only!";
  auth_basic_user_file  .userdb;
         }
#Rewrite rules
large_client_header_buffers 4 8k;

  # serve static files directly
  location ~* \.(jpg|jpeg|gif|css|png|js|ico|html)$ {
  #location ~*
\.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|flv|mp3)$
{
    access_log off;
    expires max;
  }

 location ~ \.php$ {
 #location = /index.php {
            #root           html;
            root           /home/web/mydomain.com;
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_param  SCRIPT_FILENAME 
/home/web/mydomain.com$fastcgi_script_name;
            include        fastcgi_params;
            try_files $uri $uri/ /index.php?q=$request_uri;
        }

  location ~ /\. {
    deny  all;
  }
  location ~ /(.+)\.xml$ {
    deny all;
  }
}"

Posted at Nginx Forum: http://forum.nginx.org/read.php?2,205299,205723#msg-205723




More information about the nginx mailing list