I have 3 domain name, 1 server and 1 IPv4 and 1ipv6. I’ve set a record to my ipv4 (I doesn’t use IPv6 right now). My 3 sites use Wordpress. I have configured Nginx, and php-fpm for a domain.
/etc/nginx/conf.d/php5-fpm :
upstream php5-fpm-sock {
server unix:/var/run/php5-fpm.sock; }
/etc/nginx/sites-available/domain.com.conf :
server {
listen 80;
server_name domain.com;
root /var/www/domain.com;
index index.php index.html;
#charset koi8-r;
access_log /var/log/nginx/domain.com.access.log;
error_log /var/log/nginx/domain.com.error.log;
#include global/common.conf;
#include global/wordpress.conf;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_pass php5-fpm-sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
/etc/nginx/sites-available/totaly-different-domain.com.conf :
server {
listen 80;
server_name totaly-different-domain.com;
root /var/www/totaly-different-domain.com;
index index.php index.html;
#charset koi8-r;
access_log /var/log/nginx/totaly-different-domain.com.access.log;
error_log /var/log/nginx/totaly-different-domain.com.error.log;
#include global/common.conf;
#include global/wordpress.conf;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_index index.php;
fastcgi_pass php5-fpm-sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
}
Problem : domain 1 appears on my navigator when I type domain.com but also when I type totaly-different-domain.com.
- domain.com -> show domain.com
- totaly-different-domain.com -> show domain.com
PS : I know I can optimize that but I want to understand why I have got this problem before.
UPDATE 1 :
Here are my working files :
/etc/nginx/sites-available/domain.com.conf :
server {
server_name domain.com www.domain.com;
root /var/www/domain.com/;
index index.php index.html;
access_log /var/log/nginx/domain.com.access.log;
error_log /var/log/nginx/domain.com.error.log;
include global/common.conf;
include global/wordpress.conf;
}
/etc/nginx/sites-available/totaly-different-domain.com.conf :
server {
server_name totaly-different-domain.com www.totaly-different-domain.com;
root /var/www/totaly-different-domain.com/;
index index.php index.html;
access_log /var/log/nginx/totaly-different-domain.com.access.log;
error_log /var/log/nginx/totaly-different-domain.com.error.log;
include global/common.conf;
include global/wordpress.conf;
}
/etc/nginx/global/common.conf :
# Global configuration file.
# ESSENTIAL : Configure Nginx Listening Port
listen 80;
# ESSENTIAL : Default file to serve. If the first file isn't found,
index index.php index.html index.htm;
# ESSENTIAL : no favicon logs
location = /favicon.ico {
log_not_found off;
access_log off;
}
# ESSENTIAL : robots.txt
location = /robots.txt {
allow all;
log_not_found off;
access_log off;
}
# ESSENTIAL : Configure 404 Pages
error_page 404 /404.html;
# ESSENTIAL : Configure 50x Pages
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root /usr/share/nginx/www;
}
# SECURITY : Deny all attempts to access hidden files .abcde
location ~ /\. {
access_log off;
log_not_found off;
deny all;
}
# PERFORMANCE : Set expires headers for static files and turn off logging.
location ~* ^.+\.(js|css|swf|xml|txt|ogg|ogv|svg|svgz|eot|otf|woff|mp4|ttf|rss|$
access_log off;
log_not_found off;
expires 30d;
}
/etc/nginx/global/wordpress.conf :
# WORDPRESS : Rewrite rules, sends everything through index.php and keeps the a$
location / {
try_files $uri $uri/ /index.php?$args;
}
# SECURITY : Deny all attempts to access PHP Files in the uploads directory
location ~* /(?:uploads|files)/.*\.php$ {
deny all;
}
# REQUIREMENTS : Enable PHP Support
location ~ \.php$ {
# SECURITY : Zero day Exploit Protection
try_files $uri =404;
fastcgi_index index.php;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass php5-fpm-sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include /etc/nginx/fastcgi_params;
}
Ok I have find solution. You must replace :
by
Same thing for domain.com.
You do not need to replace
with
Using the configurations you posted I was unable to reproduce your problem. Your issue is not with your configuration.
Trying temporarily replacing the contents of index.php with
and visit each site. If the correct server name is displayed for each domain, you may find this link helpful. http://tommcfarlin.com/resolving-the-wordpress-multisite-redirect-loop/