Nginx multiples domains (wordpress) on same IP

Hi folks,

I'm using webmin / virtualmin (of course ;) )

I"ve migrated from apache to nginx

All is working fine on my domain1 under wordpress with HTTPS (HSTS) via let's encrypt This domain1 have subdomains and all is working fine too

But i decided to set another domain ( domain2) with wordpress with webmin/virtualmin like i did for domain 1 with webmin/virtualmin....

And when i try to install wordpress on it via https://domain2.com/wp-admin/install.php, i've a 404 error. It seems i cannot reach domain2 because i see favicon from domain1 on my browser. I try too to reach a simple html file on this domain2 but without success. My SSL cert for domain2 is good, my browser tells me it's secured.

I've set attachments: conf-nginx-domaine1.txt (my nginx conf for domain 1 from /etc/nginx/sites-available/domain1.com.conf) conf-nginx-domaine2.txt (my nginx conf for domain 2 from /etc/nginx/sites-available/domain2.com.conf) nginx.conf fast_cgi-params dns-domain1.txt (conf from my domain name registrar for domain 1) dns-domain2.txt (conf from my domain name registrar for domain 2)

I can send other files if needed

I did several tests like disabling ssl for domain2, disabling redirect http to https, etc.. but same problem, i'm redirected to domain1. I reload nginx server and php7.0-fpm after each tests.

Thanks for helping me :)

Best

Status: 
Closed (fixed)

Comments

Assigned: » Unassigned

Howdy -- hmm, that's an odd one!

I might try starting with something simple -- first, put a simple index.html file in domain2's public_html folder, with "hello world" or similar in it.

Then, restart Nginx, just to be super-sure that the most recent config is loaded.

Once you do that, try browsing to domain2 in your browser (going to http://domain2.com).

Do you see the index.html file, or are you seeing domain1's content?

If it's still incorrect, is your server by chance behind a NAT router, and using an internal IP address?

Hi Andreychek,

Thanks for your feedback

I've already test a simple html file but it's still incorrect

Yes, my web server has a private Internal IP adress, why ?

Best

Well, I'll be honest, I'm a lot more familiar with Apache than Nginx.

But in the Apache world, you'd want it listening on the server's IP, and not the public IP (which isn't necessarily on the server).

I see "Listen" lines in your config files that are listening on the public IP though, and I'm wondering if maybe those should be listening on the server's internal IP.

It might be working on the one, simply because it's the first one in Nginx, making it the default.

My suggestion would be to try and change any references to the public IP over to the server's internal IP, restart Nginx, and see if that helps.

Hi,

Finally, my private IP is for RPN only and it's not suitable for nginx

Other suggestions ?

I've removed ip from listen block by that:

    listen 443 ssl http2;
    listen [::]:443;

My domain 1 is still working but not my domain2

So, Ip is not needed in my conf i guess but i 've same problem

I someone having generic conf files for multiple domains on same ip ?

You mentioned public and private IPs - is the address assigned to eth0 on your server a real internet address, or something in a private range like 192.168 ?

It's OK, i found a solution

I add this line on my domain2.conf:

server {
    listen 80;
    #  HTTPs activation to authorize redirections
    # HTTPs must be activated before other operations like redirections
    listen 443 ssl http2;
    listen [::]:443 ssl http2;
    server_name .domain2.com;

    ssl_certificate /home/domain2/ssl.cert;
    ssl_certificate_key /domain2/ssl.key;

    ## Redirect HTTP to HTTPS ##
    location / {
        return 301 https://www.domain2.com$request_uri$is_args$args;
        access_log off;
    }

It it can help :) and thanks anyway to those who try to help me

Best

Status: Active » Closed (fixed)