NGINX configuration

I recently configured NginX to run on port 8080, and I thought that I would share my configuration file (nginx.conf).


#user nobody;
worker_processes 1;

#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log debug;
#pid logs/nginx.pid;

events {
worker_connections 10240;
}

http {
include mime.types;
default_type application/json;
log_format gzip '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent"';

#log_format accounting_log '$time_local,0,$firm_id,$request_ip,Nginx,Lookup,$successFailure,"$request",$http_user_agent,$status,$upstream_response_time';
access_log off;

sendfile on;
keepalive_timeout 65;

#gzip on;

server {
listen *:8080;
error_page 500 502 503 504 403 404 405 = /cache_miss_js;
set $logFile "logs/nginx.log";

location ~* \.php.* {
#access_log $logFile accounting_log;

if ($remote_addr ~* ([0-9]+).([0-9]+).([0-9]+).([0-9]+)) {
set $request_ip $remote_addr;
}
if ($http_x_clientip ~* ([0-9]+).([0-9]+).([0-9]+).([0-9]+)) {
set $request_ip $http_x_clientip;
}

add_header X-ClientIP $request_ip;

root html/start/public;
#fastcgi_pass 127.0.0.1:9000;
fastcgi_pass php_servers;
fastcgi_pass_header Set-Cookie;
#fastcgi_connect_timeout 50;
#fastcgi_read_timeout 50;
fastcgi_next_upstream timeout error;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME ./html/start/public$fastcgi_script_name; #this is the one line for edition
include fastcgi_params;

if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
}

location / {
error_page 500 502 503 504 = /index.php;
error_page 403 404 405 = /index.php;
access_log $logFile gzip;
if (!-e $request_filename) {
rewrite ^.*$ /index.php last;
}
}

}
}

It is just a development instanstance of Nginx.

The above configuration file works with rewrite rules for Zend Framework.

NginX config
http://wiki.nginx.org/Configuration

Leave a Reply