By thinknew
I have no idea how this happened but after moving my site (xxxx.nz) into a new droplet from my old vps, while I was generating a Let’s Encrypt certificate a 301 re-direct has appeared to a completely non related domain (yyyy.nz) on my server…
My question is - How can I best reverse This?
This is the HTTP Status:
:~$ curl -I https://xxxx.nz
HTTP/2 301
server: nginx
date: Sun, 06 Oct 2019 23:57:55 GMT
content-type: text/html; charset=UTF-8
location: https://yyyy.nz/
expires: Wed, 11 Jan 1984 05:00:00 GMT
cache-control: no-transform, no-cache, must-revalidate, max-age=0
x-redirect-by: WordPress
strict-transport-security: max-age=31536000; includeSubdomains
content-security-policy: default-src 'self' https: data: 'unsafe-inline' 'unsafe-eval';
x-xss-protection: 1; mode=block
x-frame-options: SAMEORIGIN
x-content-type-options: nosniff
this is the sites-enabled Host File:
:~$ cat /etc/nginx/sites-enabled/xxxx.nz
server {
server_name xxxx.nz www.xxxx.nz;
access_log /home/xxxx.nz/logs/access.log;
error_log /home/xxxx.nz/logs/error.log;
root /home/xxxx.nz/public/;
index index.php;
location / {
try_files $uri $uri/ /index.php?$args;
}
location ~ \.php$ {
try_files $uri =404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass unix:/run/php/php7.2-fpm.sock;
fastcgi_index index.php;
include fastcgi_params;
}
listen [::]:443 ssl http2; # managed by Certbot
listen 443 ssl http2; # managed by Certbot
ssl_certificate /etc/letsencrypt/live/xxxx.nz/fullchain.pem; # managed by Certbot
ssl_certificate_key /etc/letsencrypt/live/xxxx.nz/privkey.pem; # managed by Certbot
include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}
server {
if ($host = www.xxxx.nz) {
return 301 https://$host$request_uri;
} # managed by Certbot
listen 80;
listen [::]:80;
server_name xxxx.nz www.xxxx.nz;
return 404; # managed by Certbot
}
This is the Nginx.conf file:
:~$ cat /etc/nginx/nginx.conf
user matt;
worker_processes 4;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 4096;
multi_accept on;
}
http {
##
# Basic Settings
##
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 10m;
add_header Strict-Transport-Security "max-age=31536000; includeSubdomains";
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 15;
types_hash_max_size 2048;
server_tokens off;
client_max_body_size 64m;
# server_names_hash_bucket_size 64;
# server_name_in_redirect off;
include /etc/nginx/mime.types;
default_type application/octet-stream;
##
# SSL Settings
##
ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;
##
# Logging Settings
##
access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;
##
# Gzip Settings
##
gzip on;
# gzip_vary on;
gzip_proxied any;
gzip_comp_level 2;
# gzip_buffers 16 8k;
# gzip_http_version 1.1;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
##
# Cache Settings
##
fastcgi_cache_key "$scheme$request_method$host$request_uri";
add_header Fastcgi-Cache $upstream_cache_status;
##
# Virtual Host Configs
##
include /etc/nginx/conf.d/*.conf;
include /etc/nginx/sites-enabled/*;
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
return 444;
}
server {
listen 80;
listen [::]:80;
server_name xxxx.com;
return 301 https://$server_name$request_uri;
}
##
# Security
##
add_header Content-Security-Policy "default-src 'self' https: data: 'unsafe-inline' 'unsafe-eval';" always;
add_header X-Xss-Protection "1; mode=block" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header X-Content-Type-Options "nosniff" always;
}
Many thanks in advance for any guidance you can offer
Matt
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
Hi @thinknew,
It’s a bit hard looking at the configuration like that with yyyy and zzzz however from what I could see, everything looks alright. This leads me to believe the redirection is coming from your website/application rather than the Nginx configuration.
Is it by any chance possible you copied the website from yyyy.nz to xxxx.nz? Check your database if you have hardcoded the yyyy.nz website.
Another thing to check is your files and if you have hardcoded yyyy.nz in there as well.
Kind regards, Kalin
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.