nginx + apache 子域名重定向故障

nginx + apache 子域名重定向故障

我真的需要你们的建议,因为我在 nginx 和 apache2 子域名配置方面遇到了一些问题

首先,有一个网站(例如,site.com)和两个子域(links.site.com 和 shop.site.com),它们的文件在物理上位于与 site.com 本身相同的 FS 层次结构级别

我的托管商已根据我的要求配置了 apache 和 nginx,但它仍然无法像以前那样工作

由于某些未知且隐含的(对我来说)原因,两个子域名都指向 site.com 的主页 :(

我的假设是,发生这种情况是因为 site.com 记录在两个配置中都位于首位?!..

请帮我解决这个问题!非常感谢大家的意见 =)

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配置文件



#
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 

答案1

显然这个 apache.conf 不对。你应该有每个主机的条目。检查举个例子。

命令:

apache2 -S

将转储您的 vhost 配置并显示已配置的主机及其顺序。

相关内容