主页

索引

模块索引

搜索页面

子配置文件(实例)

默认的配置文件

 1    server {
 2        listen      80 default_server;  #默认1
 3        server_name _;              #默认2
 4        index index.html index.htm index.php;
 5        root /var/www/ci;
 6
 7        location / {
 8            if ( $request_filename !~ (index\.php|static) ) {
 9                rewrite ^/(.*)$ /index.php/$1 last;
10            }
11        }
12
13    }

PHP对应的配置文件

 1    server {
 2        listen      80;
 3        server_name test.abc.com;
 4        index index.html index.htm index.php;
 5        root /var/www/ci;
 6
 7        location / {
 8            if ( $request_filename !~ (index\.php|static) ) {
 9                rewrite ^/(.*)$ /index.php/$1 last;
10            }
11        }
12
13        location ~ .*\.(php|php5)?$ {
14            fastcgi_pass 127.0.0.1:9000;
15#            fastcgi_pass unix:/var/run/php5-fpm.sock;
16            fastcgi_index index.php;
17            include fastcgi_params;
18            fastcgi_param PATH_INFO $fastcgi_script_name;
19            fastcgi_param  SCRIPT_FILENAME    /var/www/ci$fastcgi_script_name;
20        }
21
22        location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$ {
23            expires 30d;
24        }
25
26        location ~ .*\.(js|css)?$ {
27            expires 1h;
28        }
29    }

PHP对应的包含文件fastcgi_params

 1fastcgi_param  SCRIPT_FILENAME    $document_root$fastcgi_script_name;
 2fastcgi_param  QUERY_STRING       $query_string;
 3fastcgi_param  REQUEST_METHOD     $request_method;
 4fastcgi_param  CONTENT_TYPE       $content_type;
 5fastcgi_param  CONTENT_LENGTH     $content_length;
 6
 7fastcgi_param  SCRIPT_NAME        $fastcgi_script_name;
 8fastcgi_param  REQUEST_URI        $request_uri;
 9fastcgi_param  DOCUMENT_URI       $document_uri;
10fastcgi_param  DOCUMENT_ROOT      $document_root;
11fastcgi_param  SERVER_PROTOCOL    $server_protocol;
12
13fastcgi_param  GATEWAY_INTERFACE  CGI/1.1;
14fastcgi_param  SERVER_SOFTWARE    nginx/$nginx_version;
15
16fastcgi_param  REMOTE_ADDR        $remote_addr;
17fastcgi_param  REMOTE_PORT        $remote_port;
18fastcgi_param  SERVER_ADDR        $server_addr;
19fastcgi_param  SERVER_PORT        $server_port;
20fastcgi_param  SERVER_NAME        $server_name;
21
22# PHP only, required if PHP was built with --enable-force-cgi-redirect
23fastcgi_param  REDIRECT_STATUS    200;

mobapi(ssl相关)

  1upstream applications_cluster { 
  2	 server 118.194.167.99:8001;
  3}
  4
  5
  6server { 
  7    listen       80;
  8    server_name  mobapi.747.cn; 
  9    
 10    client_max_body_size       10m;
 11    client_body_buffer_size    128k;
 12    
 13    error_page   500 502 503 504  /50x.html;
 14    root   /usr/local/www;
 15    index index.html index.htm index.php;
 16
 17    location = /50x.html {
 18    	root   /usr/local/www/nginx-dist;
 19    }
 20
 21    location = /favicon.ico {
 22    	log_not_found off;
 23	access_log off;
 24    }
 25
 26    location = /robots.txt {
 27	allow all;
 28	log_not_found off;
 29	access_log off;
 30    }
 31
 32    location ~ ^/(2|3)/user/.*$ {
 33     deny all;
 34    }
 35
 36    location ~ ^/update/app/2/.*$ {
 37     proxy_pass http://applications_cluster;
 38    }
 39
 40    location ~ ^/(2|3)/.*$ {
 41    	 if (!-e $request_filename ) {
 42    	     rewrite ^/(.*)  index.php/$1 last;
 43    	  }
 44    }
 45       
 46    location ~* \.php/2/ {
 47        fastcgi_pass   127.0.0.1:9000;
 48        fastcgi_index  index.php;
 49        fastcgi_param  SCRIPT_FILENAME  $document_root/wifi_service_2/$fastcgi_script_name;
 50        include        fastcgi_params;
 51    }
 52
 53    location ~* \.php/3/ {
 54        fastcgi_pass   127.0.0.1:9000;
 55        fastcgi_index  index.php;
 56        fastcgi_param  SCRIPT_FILENAME  $document_root/wifi_service_3/$fastcgi_script_name;
 57        include        fastcgi_params;
 58    }
 59}
 60
 61server {
 62    listen       443 ssl default;
 63    server_name  mobapi.747.cn;
 64
 65    ssl on;
 66    ssl_certificate /usr/local/etc/nginx/ca/ssl-unified.crt;
 67    ssl_certificate_key /usr/local/etc/nginx/ca/ssl.key;
 68
 69    add_header              Front-End-Https   on;
 70    add_header		    host	      $host;
 71    error_page   500 502 503 504  /50x.html;
 72    root   /usr/local/www;
 73    index index.html index.htm index.php;
 74
 75    location = /50x.html {
 76    	root   /usr/local/www/nginx-dist;
 77    }
 78
 79    location = /favicon.ico {
 80    	log_not_found off;
 81	access_log off;
 82    }
 83
 84    location = /robots.txt {
 85	allow all;
 86	log_not_found off;
 87	access_log off;
 88    }    
 89 
 90    if (!-e $request_filename) {
 91    	rewrite ^/(.*)  index.php/$1 last;
 92    }
 93       
 94    location ~* \.php/2/ {
 95        fastcgi_pass   127.0.0.1:9000;
 96        fastcgi_index  index.php;
 97        fastcgi_param  SCRIPT_FILENAME  $document_root/wifi_service_2/$fastcgi_script_name;
 98        include        fastcgi_params;
 99    }
100
101    location ~* \.php/3/ {
102        fastcgi_pass   127.0.0.1:9000;
103        fastcgi_index  index.php;
104        fastcgi_param  SCRIPT_FILENAME  $document_root/wifi_service_3/$fastcgi_script_name;
105        include        fastcgi_params;
106    }
107}

主页

索引

模块索引

搜索页面