Issue with Virtual Hosting with FastCGI

mike mike503 at gmail.com
Tue Jun 17 01:17:47 MSD 2008


you can simplify the fastcgi stuff and put it in the global http
section, i seem to have no issue:

http {

... etc ...

        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_FILENAME $document_root$fastcgi_script_name;
        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 $http_host;
        #fastcgi_param SERVER_NAME $server_name;
        # PHP only, required if PHP was built with --enable-force-cgi-redirect
        #fastcgi_param REDIRECT_STATUS 200;
        fastcgi_ignore_client_abort on;
        fastcgi_buffers 32 8k;

... etc ...

then inside of each vhost:

        server {
                listen 80;
                server_name domain.com www.domain.com;
                index index.php index.html;
                root /home/path/web/domain.com;
                location ~ .php$ {
                        fastcgi_pass 127.0.0.1:11003;
                        fastcgi_index index.php;
                }
        }

most people define SCRIPT_FILENAME over and over and it can be done
with a single line.



On 6/16/08, nginx at fuse969.com <nginx at fuse969.com> wrote:
> I've been trying to setup virtual hosting for few blog sites using the
> wordpress clean urls and fastcgi. The 1st vhost comes up but when i call
> the other address it goes to the 1st vhost so not sure if its syntax issue
> here's copy of my config.. If someone could point out where my syntax maybe
> incorrect.
>
> user  nobody;
> worker_processes  8;
>
> #error_log  logs/error.log;
> #error_log  logs/error.log  notice;
> #error_log  logs/error.log  info;
>
> pid        logs/nginx.pid;
>
>
> events {
>    worker_connections  1024;
> }
>
>
> http {
>    include       conf/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  logs/access.log  main;
>
>    sendfile        on;
>    tcp_nopush     on;
>   server_names_hash_bucket_size 128;
>    #keepalive_timeout  0;
>    keepalive_timeout  15;
>
>    gzip  on;
>
>    server {
>        listen       80;
>        server_name  hottestgirlsofmyspace.net;
>        location / {
>            root   /home/brocklanders/hottestgirlsofmyspace.net;
>            index  index.php;
>
>   if (!-e $request_filename) {
>      rewrite  ^(.*)$  /index.php?q=$1  last;
>      break;
>    }
>      location ~ .php$ {
>       fastcgi_pass  localhost:9999;
>       fastcgi_index index.php;
>       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 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;
>       fastcgi_param SCRIPT_FILENAME
> /home/brocklanders/hottestgirlsofmyspace.net$fastcgi_script_name;
>       fastcgi_param QUERY_STRING $query_string;
>       fastcgi_param REQUEST_METHOD $request_method;
>       fastcgi_param CONTENT_TYPE $content_type;
>       fastcgi_param CONTENT_LENGTH $content_length;
>    }
> }
> }
> }
> server {
>  listen  80;
>  server_name drunkestpartygirls.com;
>  location / {
>  root /home/brocklanders/drunkestpartygirls.com;
>  index index.php;
> if (!-e $request_filename) {
>      rewrite  ^(.*)$  /index.php?q=$1  last;
>      break;
>    }
>      location ~ .php$ {
>       fastcgi_pass  localhost:9999;
>       fastcgi_index index.php;
>       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 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;
>       fastcgi_param SCRIPT_FILENAME
> /home/brocklanders/drunkestpartygirls.com$fastcgi_script_name;
>       fastcgi_param QUERY_STRING $query_string;
>       fastcgi_param REQUEST_METHOD $request_method;
>       fastcgi_param CONTENT_TYPE $content_type;
>       fastcgi_param CONTENT_LENGTH $content_length;
>    }
> }
> }
> }
> server {
>  listen  80;
>  server_name hottestgirlsofspringbreak.com;
>  location / {
>  root /home/brocklanders/hottestgirlsofspringbreak.com;
>  index index.php;
> if (!-e $request_filename) {
>      rewrite  ^(.*)$  /index.php?q=$1  last;
>      break;
>    }
>      location ~ .php$ {
>       fastcgi_pass  localhost:9999;
>       fastcgi_index index.php;
>       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 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;
>       fastcgi_param SCRIPT_FILENAME
> /home/brocklanders/hottestgirlsofspringbreak.com$fastcgi_script_name;
>       fastcgi_param QUERY_STRING $query_string;
>       fastcgi_param REQUEST_METHOD $request_method;
>       fastcgi_param CONTENT_TYPE $content_type;
>       fastcgi_param CONTENT_LENGTH $content_length;
>    }
> }
> }
> }
> server {
>  listen  80;
>  server_name weratevacations.com;
>  location / {
>  root /home/brocklanders/weratevacations.com;
>  index index.php;
> if (!-e $request_filename) {
>      rewrite  ^(.*)$  /index.php?q=$1  last;
>      break;
>    }
>      location ~ .php$ {
>       fastcgi_pass  localhost:9999;
>       fastcgi_index index.php;
>       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 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;
>       fastcgi_param SCRIPT_FILENAME
> /home/brocklanders/weratevacations.com$fastcgi_script_name;
>       fastcgi_param QUERY_STRING $query_string;
>       fastcgi_param REQUEST_METHOD $request_method;
>       fastcgi_param CONTENT_TYPE $content_type;
>       fastcgi_param CONTENT_LENGTH $content_length;
>    }
> }
> }
> }
> server {
>  listen  80;
>  server_name hottestflickrgirls.com;
>  location / {
>  root /home/brocklanders/hottestflickrgirls.com;
>  index index.php;
> if (!-e $request_filename) {
>      rewrite  ^(.*)$  /index.php?q=$1  last;
>      break;
>    }
>      location ~ .php$ {
>       fastcgi_pass  localhost:9999;
>       fastcgi_index index.php;
>       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 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;
>       fastcgi_param SCRIPT_FILENAME
> /home/brocklanders/hottestflickrgirls.com$fastcgi_script_name;
>       fastcgi_param QUERY_STRING $query_string;
>       fastcgi_param REQUEST_METHOD $request_method;
>       fastcgi_param CONTENT_TYPE $content_type;
>       fastcgi_param CONTENT_LENGTH $content_length;
>    }
> }
> }
> }
> server {
>  listen  80;
>  server_name hottestgirlsofnightclubs.com;
>  location / {
>  root /home/brocklanders/hottestgirlsofnightclubs.com;
>  index index.php;
> if (!-e $request_filename) {
>      rewrite  ^(.*)$  /index.php?q=$1  last;
>      break;
>    }
>      location ~ .php$ {
>       fastcgi_pass  localhost:9999;
>       fastcgi_index index.php;
>       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 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;
>       fastcgi_param SCRIPT_FILENAME
> /home/brocklanders/hottestgirlsofnightclubs.com$fastcgi_script_name;
>       fastcgi_param QUERY_STRING $query_string;
>       fastcgi_param REQUEST_METHOD $request_method;
>       fastcgi_param CONTENT_TYPE $content_type;
>       fastcgi_param CONTENT_LENGTH $content_length;
>    }
> }
> }
> }
> server {
>  listen  80;
>  server_name sexualaddictionresources.com;
>  location / {
>  root /home/brocklanders/sexualaddictionresources.com;
>  index index.php;
> if (!-e $request_filename) {
>      rewrite  ^(.*)$  /index.php?q=$1  last;
>      break;
>    }
>      location ~ .php$ {
>       fastcgi_pass  localhost:9999;
>       fastcgi_index index.php;
>       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 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;
>       fastcgi_param SCRIPT_FILENAME
> /home/brocklanders/sexualaddictionresources.com$fastcgi_script_name;
>       fastcgi_param QUERY_STRING $query_string;
>       fastcgi_param REQUEST_METHOD $request_method;
>       fastcgi_param CONTENT_TYPE $content_type;
>       fastcgi_param CONTENT_LENGTH $content_length;
>    }
> }
> }
> }
> server {
>  listen  80;
>  server_name hottestgirlsofcheerleading.com;
>  location / {
>  root /home/brocklanders/hottestgirlsofcheerleading.com;
>  index index.php;
> if (!-e $request_filename) {
>      rewrite  ^(.*)$  /index.php?q=$1  last;
>      break;
>    }
>      location ~ .php$ {
>       fastcgi_pass  localhost:9999;
>       fastcgi_index index.php;
>       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 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;
>       fastcgi_param SCRIPT_FILENAME
> /home/brocklanders/hottestgirlsofcheerleading.com$fastcgi_script_name;
>       fastcgi_param QUERY_STRING $query_string;
>       fastcgi_param REQUEST_METHOD $request_method;
>       fastcgi_param CONTENT_TYPE $content_type;
>       fastcgi_param CONTENT_LENGTH $content_length;
>    }
> }
> }
> }
>
> server {
>  listen  80;
>  server_name hottestgirlsofsororities.com;
>  location / {
>  root /home/brocklanders/hottestgirlsofsororities.com;
>  index index.php;
> if (!-e $request_filename) {
>      rewrite  ^(.*)$  /index.php?q=$1  last;
>      break;
>    }
>      location ~ .php$ {
>       fastcgi_pass  localhost:9999;
>       fastcgi_index index.php;
>       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 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;
>       fastcgi_param SCRIPT_FILENAME
> /home/brocklanders/hottestgirlsofsororities.com$fastcgi_script_name;
>       fastcgi_param QUERY_STRING $query_string;
>       fastcgi_param REQUEST_METHOD $request_method;
>       fastcgi_param CONTENT_TYPE $content_type;
>       fastcgi_param CONTENT_LENGTH $content_length;
>    }
> }
> }
> }
> server {
>  listen  80;
>  server_name uncoached.com;
>  location / {
>  root /home/brocklanders/uncoached.com;
>  index index.php;
> if (!-e $request_filename) {
>      rewrite  ^(.*)$  /index.php?q=$1  last;
>      break;
>    }
>      location ~ .php$ {
>       fastcgi_pass  localhost:9999;
>       fastcgi_index index.php;
>       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 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;
>       fastcgi_param SCRIPT_FILENAME
> /home/brocklanders/uncoached.com$fastcgi_script_name;
>       fastcgi_param QUERY_STRING $query_string;
>       fastcgi_param REQUEST_METHOD $request_method;
>       fastcgi_param CONTENT_TYPE $content_type;
>       fastcgi_param CONTENT_LENGTH $content_length;
>    }
> }
> }
> }
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
> }
>
>
>





More information about the nginx mailing list