Want to subscribe to topics you're interested in?
Become a Member

Nginx Can i use different ip for every vhost on Centminmod?

Discussion in 'Install & Upgrades or Pre-Install Questions' started by pamamolf, Jul 2, 2014.

  1. pamamolf

    pamamolf Premium Member Premium Member

    4,084
    428
    83
    May 31, 2014
    Ratings:
    +834
    Local Time:
    6:45 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    Hi

    Can i use different ip for every vhost on Centminmod?


    Thanks :)
     
  2. rdan

    rdan Well-Known Member

    5,446
    1,408
    113
    May 25, 2014
    Ratings:
    +2,201
    Local Time:
    12:45 PM
    Mainline
    10.2
    I think it's possible.
    You declare it's IP on each domain.conf
     
  3. pamamolf

    pamamolf Premium Member Premium Member

    4,084
    428
    83
    May 31, 2014
    Ratings:
    +834
    Local Time:
    6:45 AM
    Nginx-1.25.x
    MariaDB 10.3.x
    Ok thanks RoldanLT :)

    I will wait for George to confirm it also just to be sure :)
     
  4. eva2000

    eva2000 Administrator Staff Member

    54,600
    12,225
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,794
    Local Time:
    2:45 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    yes in each domain.com vhost file's listen directive http://nginx.org/en/docs/http/ngx_http_core_module.html#listen

    Code:
     server {
                listen ipaddress1  80;
    
      server_name yourdomainname.com www.yourdomainname.com;
    Code:
     server {
                listen ipaddress2  80;
    
      server_name yourdomainname.com www.yourdomainname.com;
    provided you have added additional ip addresses to your server i.e. http://www.cyberciti.biz/faq/linux-creating-or-adding-new-network-alias-to-a-network-card-nic/ or http://knowledgelayer.softlayer.com/procedure/assign-additional-ip-addresses-redhatcentos
     
  5. nVidian

    nVidian Member

    98
    8
    8
    Mar 16, 2015
    Ratings:
    +31
    Local Time:
    11:45 AM
    1.7.9
    5.5
    Hi, I'm confused. Here's at Drupal - Nginx Community they said:
     
    Last edited: Mar 16, 2015
  6. eva2000

    eva2000 Administrator Staff Member

    54,600
    12,225
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,794
    Local Time:
    2:45 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
  7. nVidian

    nVidian Member

    98
    8
    8
    Mar 16, 2015
    Ratings:
    +31
    Local Time:
    11:45 AM
    1.7.9
    5.5
    So if I want to add different IP to one of my site, do I must insert
    Code:
    listen new_IP;
    
    at its VHOST ??

    I already tried without that line , after edit ifcfg-eth0:0 to add new IP , I point DNS A record to the new IP. So it works without that line.
    But I dont know if its correct way, especially my intend is to use SSL (single domain) for that website. Could you clear this up ?
    Thanks eva2000.
     
  8. eva2000

    eva2000 Administrator Staff Member

    54,600
    12,225
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,794
    Local Time:
    2:45 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    I personally set the separate ip in listen just serves to better identify which ip the domain is attached to if you have many ip addresses and many domains.

    You can imagine if you had 20 ips and 20 domains each with own ip, it would be a bit confusing knowing which domain goes to which ip at the local nginx vhost level.
     
  9. nVidian

    nVidian Member

    98
    8
    8
    Mar 16, 2015
    Ratings:
    +31
    Local Time:
    11:45 AM
    1.7.9
    5.5
    Yes, I even have more than 20 domains in that VPS :)
    So, I think I will follow your suggestion. Thanks eva2000.