Join the community today
Become a Member

Nginx Multiple domains

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by tech2019x, Oct 13, 2021.

  1. tech2019x

    tech2019x New Member

    2
    1
    3
    Oct 13, 2021
    Ratings:
    +1
    Local Time:
    11:49 PM
    1.21.1
    MariaDB 10.3
    Hello,

    stuck with multiple domains. This is not firts server and never had this problem.

    In server created few domains via option 2
    First domain shows right content
    Second domain shows right content
    Third domain (content exists) shows content of first domain like default

    Tried point few other domains with DNS to this server IP. In centmin domains not created. All of them opens first domain content, not nginx default html content


    Any ideas, what I misconfigured?
     
  2. eva2000

    eva2000 Administrator Staff Member

    54,647
    12,230
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,799
    Local Time:
    7:49 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Are they all HTTPS first/default based sites or some non-HTTPS ? Using HTTPS with Letsencrypt SSL certificates provided by Centmin Mod ?

    Have you setup the main hostname as per Getting Started Guide step 1? When you install Centmin Mod it's setup a main hostname nginx vhost host for server which is where Nginx default install index page is shown. Accessing server via IP address will show that page and it's correct and should be left as is as the main hostname site is also used for statistics pages outlined here. When you create a new Nginx vhost site via centmin.sh menu option 2, 22 or nv commands, you have a separate Nginx vhost directory structure. The differences are outlined on official Config file page and at Getting Started Guide step 1 and bottom of that page here.
    What does your /usr/local/nginx/conf/conf.d/virtual.conf and /usr/local/nginx/conf/conf.d/yourdomain.com.conf contents look like ? Make sure virtual.conf main hostname's server_name isn't same as any added nginx vhost site's domain name as per Getting Started Guide step 1, the main hostname needs to be unique.

    You can check via recursive grep filter for each of the three domain names in vhost directory at /usr/local/nginx/conf/conf.d
    Code (Text):
    grep -rnw 'yourdomain.com' /usr/local/nginx/conf/conf.d
    


    check HTTP headers via curl for both HTTP (and HTTPS if you have HTTPS/SSL) for each of the 3 domains
    Code (Text):
    curl -I http://yourdomain.com
    curl -I http://www.yourdomain.com
    curl -I https://yourdomain.com
    curl -I https://www.yourdomain.com
    curl -I http://hostname.yourdomain.com
    

    for posting code or output from commands to keep the formatting, you might want to use CODE tags for code How to use forum BBCODE code tags :)