0

I have a server on which I run a website at the domain example.eu. I've redirected to https and removed the www as per this answer. I now wish to add another website to the same server, at the domain test.eu. This server doesn't need www removal or https, so it is a simple server block.

The problem is that whenever I go to test.eu in my browser, I get a 301 redirect to example.eu.

example.eu conf:

upstream django {
    server unix:///home/foo/bar/example.sock; # for a file socket
}

server {
    listen 80;
    server_name example.eu www.example.eu;
    return 301 https://example.eu$request_uri;
}

server {
    listen 443 ssl;
    server_name www.example.eu;
    ssl_certificate /etc/nginx/ssl/example.cer;
    ssl_certificate_key /etc/nginx/ssl/example.key;
    return 301 https://example.eu$request_uri;
}

server {
    listen 443 ssl;
    server_name example.eu;
    ssl_certificate /etc/nginx/ssl/example.cer;
    ssl_certificate_key /etc/nginx/ssl/example.key;
    root /usr/share/nginx/html;
    index index.php;

    location /static { # STATIC_URL
        alias /home/foo/bar/static; # STATIC_ROOT
        expires max;
        add_header Pragma public;
        add_header Cache-Control "public";
    }

    location /media { # MEDIA_URL
        root /home/foo/bar/media; # MEDIA_ROOT
    }

    location / {
        include /etc/nginx/uwsgi_params;
        uwsgi_read_timeout 300;
        uwsgi_pass django;
    }
}

and the much simpler test.eu conf:

server {
    listen 80;
    server_name test.eu www.test.eu;
    root /home/foo/qux;
    index index.html;
}

I've also tried having the test.eu conf as part of the example.eu conf, at the top, but to no avail. What's going on and how do I fix this? Many thanks.

heidi
  • 41
  • 2

1 Answers1

4

It turns out that I was changing the conf files around and forgot to clear my cache, so the browser was caching the redirect. Fixed now.

Colt
  • 2,029
  • 6
  • 21
  • 27
heidi
  • 41
  • 2