我有一台运行良好(WordPress 博客)的服务器,该服务器包含多个使用 Nginx 的域名。现在我想设置一个 phplist 服务器,并将其放置在一个子域名下,但尽管我认为我配置子域名没有问题,但每次我尝试加载子域名时,请求都会直接转到我的一个域名。
这是我的域名的 Nginx 配置文件(我已经替换了域名):
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;
}
这是子域名的配置文件,已配置完毕Nginx 的 Wiki。如您所见,子域名来自不同的域名,而不是其重定向到的域名。
我的意思是,当我访问 phplist.myotherdomain.com 时,它会转到 www.mydomain.com。Myotherdomain 和 Mydomain 是不同的,事实上,主 myotherdomain 位于其他服务器中,单独工作(我希望保持这种状态)。这是配置文件:
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;
}
}
我认为问题出在 fastcgi 部分,但我不确定那里出了什么问题。我正在使用 PHP-FPM 和 Nginx。根文件夹没有问题,我的博客和 phplist 服务器的文件都在它们应该在的位置。
有任何想法吗?