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 really need your advice folks since i'm experiencing some troubles with nginx & apache2 subdomains configs

first of all, there's a site (say, site.com) and two subdomains (links.site.com and shop.site.com) whose files are physically located at the same level of FS hierarchy as the site.com itself

my hoster has configured both apache and nginx by my request, but it still doesn't work as it used to

both of subdomains point to the main page of site.com for some unknown and implicit (for me) reason :(

my assumption is that's happen because site.com record is placed first in both configs?!..

please help me solve this out! every opinion would be appreciated =)

nginx.conf:

server {
    listen       95.169.187.234:80;
    server_name  site.com www.site.com
;

    access_log  /home/www/site.com/logs/nginx.access.log  main;
location ~* ^.+\.(jpeg|jpg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|avi|mp3|mpg|mpeg|asf|vmw)$ {
        expires 30d;
        root /home/www/site.com/www;
}

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }

location / {
  set                $referer  $http_referer;
  proxy_pass         http://127.0.0.1:8080/;
  proxy_redirect     off;
  proxy_set_header   X-Real-IP        $remote_addr;
  proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
  proxy_set_header   Referer              $referer;
  proxy_set_header   Host             $host;
  client_max_body_size       10m;
  client_body_buffer_size    64k;
  proxy_connect_timeout      90;
  proxy_send_timeout         90;
  proxy_read_timeout         90;
  proxy_buffer_size          4k;
  proxy_buffers              4 32k;
  proxy_busy_buffers_size    64k;
  proxy_temp_file_write_size 64k;
}
}

server {
    listen       95.169.187.234:80;
    server_name  links.site.com www.links.site.com
;

    access_log  /home/www/links.site.com/logs/nginx.access.log  main;
location ~* ^.+\.(jpeg|jpg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|avi|mp3|mpg|mpeg|asf|vmw)$ {
        expires 30d;
        root /home/www/links.site.com/www;
}

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }

location / {
  set                $referer  $http_referer;
  proxy_pass         http://127.0.0.1:8080/;
  proxy_redirect     off;
  proxy_set_header   X-Real-IP        $remote_addr;
  proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
  proxy_set_header   Referer              $referer;
  proxy_set_header   Host             $host;
  client_max_body_size       10m;
  client_body_buffer_size    64k;
  proxy_connect_timeout      90;
  proxy_send_timeout         90;
  proxy_read_timeout         90;
  proxy_buffer_size          4k;
  proxy_buffers              4 32k;
  proxy_busy_buffers_size    64k;
  proxy_temp_file_write_size 64k;
}
}

server {
    listen       95.169.187.234:80;
    server_name  shop.site.com www.shop.site.com
;

    access_log  /home/www/shop.site.com/logs/nginx.access.log  main;
location ~* ^.+\.(jpeg|jpg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js|swf|avi|mp3|mpg|mpeg|asf|vmw)$ {
        expires 30d;
        root /home/www/shop.site.com/www;
}

    #error_page  404              /404.html;

    # redirect server error pages to the static page /50x.html
    #
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   html;
    }

    # deny access to .htaccess files, if Apache's document root
    # concurs with nginx's one
    #
    location ~ /\.ht {
        deny  all;
    }

location / {
  set                $referer  $http_referer;
  proxy_pass         http://127.0.0.1:8080/;
  proxy_redirect     off;
  proxy_set_header   X-Real-IP        $remote_addr;
  proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
  proxy_set_header   Referer              $referer;
  proxy_set_header   Host             $host;
  client_max_body_size       10m;
  client_body_buffer_size    64k;
  proxy_connect_timeout      90;
  proxy_send_timeout         90;
  proxy_read_timeout         90;
  proxy_buffer_size          4k;
  proxy_buffers              4 32k;
  proxy_busy_buffers_size    64k;
  proxy_temp_file_write_size 64k;
}
} 

httpd.conf:



#
ServerRoot "/usr/local/apache2"
PidFile /var/run/httpd.pid
Timeout 300
KeepAlive On
MaxKeepAliveRequests 100
KeepAliveTimeout 15

Listen 127.0.0.1:8080
NameVirtualHost 127.0.0.1:8080

...

#Listen *:80

NameVirtualHost *:80


    ServerName www.site.com
    ServerAlias site.com
    UseCanonicalName Off
    CustomLog /home/www/site.com/logs/custom_log combined
    ErrorLog /home/www/site.com/logs/error_log
    DocumentRoot /home/www/site.com/www
    
    AllowOverride All
    Options +FollowSymLinks
    Options -MultiViews
    Options -Indexes
        Options Includes
        Order allow,deny
        Allow from all
    
    DirectoryIndex index.html index.htm index.php



    ServerName www.links.site.com
    ServerAlias links.site.com
    UseCanonicalName Off
    CustomLog /home/www/links.site.com/logs/custom_log combined
    ErrorLog /home/www/links.site.com/logs/error_log
    DocumentRoot /home/www/links.site.com/www
    
        AllowOverride All
        Options +FollowSymLinks
        Options -MultiViews
        Options -Indexes
        Options Includes
        Order allow,deny
        Allow from all
    
    DirectoryIndex index.html index.htm index.php



    ServerName www.shop.site.com
    ServerAlias shop.site.com
    UseCanonicalName Off
    CustomLog /home/www/shop.site.com/logs/custom_log combined
    ErrorLog /home/www/shop.site.com/logs/error_log
    DocumentRoot /home/www/shop.site.com/www
    
        AllowOverride All
        Options +FollowSymLinks
        Options -MultiViews
        Options -Indexes
        Options Includes
        Order allow,deny
        Allow from all
    
    DirectoryIndex index.html index.htm index.php


# if DSO load module first:
LoadModule rpaf_module modules/mod_rpaf-2.0.so

RPAFenable On
RPAFsethostname On
RPAFproxy_ips 127.0.0.1
RPAFheader X-Forwarded-For


Include conf/virthost/*.conf 

share|improve this question

1 Answer 1

Apparently this apache.conf is not... right. You should have entries to each host. Check this and this for an example.

The command:

apache2 -S

will dump your vhost configuration and show what hosts are configured and their order.

share|improve this answer
    
tnx for your response! i've fixed the issue by typing: NameVirtualHost 127.0.0.1:8080 to catch the proxy flow redirected by nginx –  webwolf Jul 31 '10 at 17:30

Your Answer

 
discard

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