Dear community,

I am a beginner in the land of nginx and server administration. From what
I've read so far, setting up nginx to listen to two domains is fairly easy.
All it needs are two distinct server blocks listen to port 80 and with
server_name identical to the domains in question. But it will not work.

I have to domains: www.3jgkp.de and www.armapedia.de. Both a registered by
www.inwx.de and both have A DNS entries to the same server IP 88.99.227.139,
which is my server. For 3.jgkp I use one additional subdomain wiki.3jgkp.de,
which also redirects to this IP.

Now it should suffice to have

server {
    listen 80;
    listen [::]:80;
    
    server_name .3jgkp.de;

    index index.html index.htm index.php;

    ....
}

server {
    listen *:80;
    listen [::]:80;

    server_name wiki.3jgkp.de;
    return 301 https://wiki.3jgkp.de$request_uri;
   
   ....

}  

server {
    listen *:443 ssl;
    server_name wiki.3jgkp.de;
   
    index index.php;
    root /var/www/wiki/drupal-8.2.6; ## <-- Your only path reference.
    client_max_body_size 10m;
    ssl_certificate /etc/letsencrypt/live/wiki.3jgkp.de-0001/fullchain.pem;
# managed by Certbot
    ssl_certificate_key
/etc/letsencrypt/live/wiki.3jgkp.de-0001/privkey.pem; # managed by Certbot

   ....
}

for www.3jgkp.de -> that works, both directories are delivered. However,
www.armapedia.de does NOT work:

server {
    listen 80;
    listen [::]:80;
    server_name .armapedia.de;
    return 301 https://www.armapedia.de$request_uri;

}  

server {
    listen 443 ssl;
    server_name www.armapedia.de;
        
    root /var/www/armapedia/; ## <-- Your only path reference.
    access_log /var/log/nginx/armapedia.de.access.log;
    error_log /var/log/nginx/armapedia.de.error.log;

    ssl_certificate /etc/letsencrypt/live/www.armapedia.de/fullchain.pem; #
managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/www.armapedia.de/privkey.pem;
# managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
}

Here, whenever I enter www.armapedia.de in my browser, I am redirected to
armapedia.3jgkp.de. I dont understand this behavior at all. All examples
about nginx and multiple vhosts with different domains just use the
appropriate server_name entries, so I'm really stuck here.

Thank you for your help

Posted at Nginx Forum: 
https://forum.nginx.org/read.php?2,276031,276031#msg-276031

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx

Reply via email to