Join the community today
Register Now

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

    3,522
    342
    83
    May 31, 2014
    Ratings:
    +655
    Local Time:
    1:20 AM
    Nginx-1.17.x
    MariaDB 10.3.x
    Hi

    Can i use different ip for every vhost on Centminmod?

    Thanks :)
     
  2. rdan

    rdan Well-Known Member

    4,710
    1,134
    113
    May 25, 2014
    Ratings:
    +1,688
    Local Time:
    7:20 AM
    Mainline
    10.2
    I think it's possible.
    You declare it's IP on each domain.conf
     
    • Like Like x 1
  3. pamamolf

    pamamolf Premium Member Premium Member

    3,522
    342
    83
    May 31, 2014
    Ratings:
    +655
    Local Time:
    1:20 AM
    Nginx-1.17.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

    41,998
    9,473
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,577
    Local Time:
    9:20 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    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
     
    • Like Like x 5
  5. nVidian

    nVidian Member

    92
    8
    8
    Mar 16, 2015
    Ratings:
    +23
    Local Time:
    6:20 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

    41,998
    9,473
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,577
    Local Time:
    9:20 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
  7. nVidian

    nVidian Member

    92
    8
    8
    Mar 16, 2015
    Ratings:
    +23
    Local Time:
    6:20 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

    41,998
    9,473
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +14,577
    Local Time:
    9:20 AM
    Nginx 1.17.x
    MariaDB 5.5/10.x
    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

    92
    8
    8
    Mar 16, 2015
    Ratings:
    +23
    Local Time:
    6:20 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.