Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I've got a server with serveral domains under Nginx running fine (WordPress blogs). Now I want to setup a phplist server and locate it under one subdomain, but although I thought I configured the subdomain without problems, everytime I try to load the subdomain the request goes straight away to one of my domains.

This is the Nginx config file for my domain (I've replaced the domain name):

server  {
    listen  80;
    server_name  mydomain.com  www.mydomain.com;
#    error_log /var/www/mydomain/mydomain_error.log;                                                                
    root  /var/www/mydomain/;

    location ~* ^.+.(bz2|jpe?g|gif|gz|png|ico|css|zip|rar|doc|xls|exe|pdf|ppt|txt|tar|tgz|mid|midi|mp3|wav|bmp|rtf\
|js|swf|avi|m2t|mkv)$ {
        access_log  off;
        expires  30d;
        root  /var/www/mydomain/;
    }

              location / {
                 index index.php;
                 client_max_body_size 3M;
                 try_files $uri $uri/ /index.php?q=$uri&$args;
                 # if the requested file exists, return it immediately                                              
                 if (-f $request_filename) {
                    break;
                 }

                 #if ($http_user_agent !~ FeedBurner) {                                                             
                   # rewrite ^/comment/feed/ http://feeds.feedburner.com/your-comment-feed last;                    
                  # rewrite ^/feed/ http://feeds.feedburner.com/Muypymes last;                                      
                  # }                                                                                               
                if ($http_user_agent !~ "^MediafedMetrics.*") {
                        rewrite ^/feed/?$ http://feeds.feedburner.com/Muypymes last;
              }


                        # all other requests go to WordPress                                                        
                                if (!-e $request_filename) {
                                rewrite . /index.php last;
                                }
              }

              ## Parse all .php file in the /var/www directory                                                      
              location ~ .php$ {
                 fastcgi_split_path_info ^(.+\.php)(.*)$;
                 fastcgi_pass   backend;
                 fastcgi_index  index.php;
                 fastcgi_param  SCRIPT_FILENAME  /var/www/mydomain/$fastcgi_script_name;
                 include 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_intercept_errors        on;
                 fastcgi_ignore_client_abort     on;
                 fastcgi_read_timeout 360;
              }


              ## Disable viewing .htaccess & .htpassword                                                            
              location ~ /\.ht {
                 deny  all;
}


              location = /favicon.ico {
                         access_log off;
                         log_not_found off;
                         }
}


upstream backend {
              server 127.0.0.1:9000;

}

And this is the subdomain's config file, that has been configured after Nginx's Wiki. As you can see, the subdomain is from a different domain, not the one it redirects to.

I mean, when I go to phplist.myotherdomain.com, it goes to www.mydomain.com. Myotherdomain and Mydomain are different, and in fact the main myotherdomain is in other server, working sepparately (and I'd like to keep it like this). This is the config file:

server {
                listen 80;
                server_name phplist.myotherdomain.com;

                root /var/www/phplist/public_html/lists;
                index index.php;

                #access_log <<log file>>;
                #error_log <<log file>>;

                charset utf-8;

                location ~* \.(txt|log|inc)$ {
                    allow 127.0.0.1;
                    deny all;
                }

                location ~* \.(js|css|png|jpg|jpeg|gif|ico)$ {
                  expires max;
                  log_not_found off;
               }

                #block phplist config directory
                location /config {
                    deny all;
                }

                #per the phplist .htaccess these are the only public allowed php files
                location ~* (index\.php|upload\.php|connector\.php|dl\.php|ut\.php|lt\.php|download\.php)$ {
                       fastcgi_split_path_info ^(.|\.php)(/.+)$;

                       include /etc/nginx/fastcgi_params.conf; #standar fastcgi config file
                       fastcgi_param SCRIPT_FILENAME /var/www/phplist/public_html/lists$fastcgi_script_name;
                       fastcgi_intercept_errors on;
                       fastcgi_pass 127.0.0.1:9000;
                }


                #block all other php file access from public
                location ~ \.php$ {
                   deny all;
                }

}

I think the problem lies in the fastcgi part, but I'm not sure what's wrong there. I'm using PHP-FPM together with Nginx. The root folders are OK, and the files of my blogs and phplist server are where the are supposed to be.

Any ideas?

share|improve this question
    
Uncomment the error_log directive and take a look at this. –  quanta Nov 7 '11 at 13:28
    
Does the client get redirected to www.mydomain.com, or does the server return the content for www.mydomain.com but under the phplist.myotherdomain.com domain? Is the static content also wrong? –  mgorven Mar 30 '12 at 3:55

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.