我必须要重定向到一个 nginx 服务器的子域:first.domainOne.com 和 second.domainTwo.net
我的 nginx 站点可用目录中有两个文件(每个文件都有一个符号链接指向站点启用): first.server 文件内容:
server {
root /usr/share/nginx/www;
index index.html index.htm;
server_name first.domainOne.com;
location / {
try_files $uri $uri/ /index.html;
}
location ~ \.php$ {
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/var/run/php5-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
}
second.server 文件内容:
server{
server_name second.domainTwo.net;
root /usr/share/nginx/test;
index index.html index.htm;
location / {
try_files $uri $uri/ /index.html;
}
}
当我启用这两个文件时,我只能访问 /usr/share/nginx/www 的内容(如果我去 first.domainOne.com 或 second.domainTwo.net)。
我必须能够显示第二台服务器的内容(/usr/share/nginx/test)的唯一方法是从站点启用中禁用(删除)first.server 文件。
这是我的 nginx.conf :
user www-data;
worker_processes 4;
pid /var/run/nginx.pid;
events {
worker_connections 768;
}
http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
gzip on;
gzip_disable "msie6";
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
}
编辑:两个重定向都直接指向服务器名称(即http://server.name),但调试日志显示它检测到使用的两个不同的 URL):
http://first.domainOne.com -> http://server.name
http://second.domainTwo.net -> http://server.name
server.name 是托管我的 nginx 实例的服务器。
我想念什么?我的配置文件不正确还是需要激活 nginx.conf 中的选项?