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

Sysadmin Setup multiple websites with multiple IPs on SoYouStart (OVH)?

Discussion in 'System Administration' started by Afaq, Apr 29, 2017.

  1. Afaq

    Afaq Member

    46
    1
    8
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    2:10 PM
    I just got a SoYouStart server, running CentOS 7 and Centmin on it. Currently, I am running only 1 website on it however I am thinking of adding a couple of more websites to it. However, I want each website to have its own dedicated IP. SYS offers up to 16 IPs with each server for $1 per IP.

    I want to ask how do I setup each website to have it own IP?
     
  2. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    5:10 AM
    1.13.x
    MariaDB 10.1.x
    1. Add the new ip to the interfaces.

    2. Add the new ip to the vhost of the site.

    Code:
    server {
    listen XXX.XXX.XXX.XXX:80;
    
     
    • Agree Agree x 1
  3. Afaq

    Afaq Member

    46
    1
    8
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    2:10 PM
    That's it?
     
  4. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    5:10 AM
    1.13.x
    MariaDB 10.1.x
    Yup. You'll have to do the same thing for :443 if you're using secure, but that's pretty much it.
     
    • Like Like x 1
  5. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    5:10 AM
    1.13.x
    MariaDB 10.1.x
    Oh, make sure you point your DNS A record for whatever.com to that IP4 address and AAAA to IP6 address.
     
    • Like Like x 1
  6. eva2000

    eva2000 Administrator Staff Member

    30,161
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    7:10 PM
    Nginx 1.13.x
    MariaDB 5.5
    yup that's it basically :D
     
  7. Afaq

    Afaq Member

    46
    1
    8
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    2:10 PM
    I have set it up as you guys mentioned but the second site is not opening. The second IP is showing up as fallover IP in the SyS admin panel, could that be the reason?
     
  8. eva2000

    eva2000 Administrator Staff Member

    30,161
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    7:10 PM
    Nginx 1.13.x
    MariaDB 5.5
    you need to configure and add ips to your server too the OVH dashboard doesn't do that for you

    add additional ips as per Network IP Aliasing | OVH Docs
     
  9. Afaq

    Afaq Member

    46
    1
    8
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    2:10 PM
    I have now added the IP to the server using the link above. Another issue now, the domain is now showing the Centmin Nginx Test page, not the index.html page of that domain.
     
  10. eva2000

    eva2000 Administrator Staff Member

    30,161
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    7:10 PM
    Nginx 1.13.x
    MariaDB 5.5
    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.
     
  11. Afaq

    Afaq Member

    46
    1
    8
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    2:10 PM
    Here is my virtual.conf:

    Code:
    server {
    #         listen   80;
                listen   80 default_server backlog=2048 reuseport;
                server_name ns305767.ip-91-121-221.eu;
                root   html;
    
            access_log              /var/log/nginx/localhost.access.log     main buffer=256k flush=5m;
            error_log               /var/log/nginx/localhost.error.log      error;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
    # limit_conn limit_per_ip 16;
    # ssi  on;
    
            location /nginx_status {
            stub_status on;
            access_log   off;
            allow 127.0.0.1;
            #allow youripaddress;
            deny all;
            }
    
                location / {
    
    # block common exploits, sql injections etc
    #include /usr/local/nginx/conf/block.conf;
    
    #         Enables directory listings when index file not found
    #        autoindex  on;
    
    #        Shows file listing times as local time
    #        autoindex_localtime on;
    
    #        Enable for vBulletin usage WITHOUT vbSEO installed
    #        try_files        $uri $uri/ /index.php;
                
                }
    
            # example nginx-http-concat
            # /csstest/??one.css,two.css
            #location /csstest {
            #concat on;
            #concat_max_files 20;
            #}
    
    include /usr/local/nginx/conf/staticfiles.conf;
    include /usr/local/nginx/conf/php.conf;
    #include /usr/local/nginx/conf/phpstatus.conf;
    include /usr/local/nginx/conf/drop.conf;
    #include /usr/local/nginx/conf/errorpage.conf;
    include /usr/local/nginx/conf/vts_mainserver.conf;
    
           }
    And here is my domain.com.conf for the second domain for which I got the new IP:

    Code:
    # Centmin Mod Getting Started Guide
    # must read http://centminmod.com/getstarted.html
    
    # redirect from non-www to www
    # uncomment, save file and restart Nginx to enable
    # if unsure use return 302 before using return 301
    server {
                listen   87.98.143.0:80;
    #            server_name gear.com.pk;
    #            return 301 $scheme://www.gear.com.pk$request_uri;
           }
    
    server {
      server_name gear.com.pk www.gear.com.pk;
    
    # ngx_pagespeed & ngx_pagespeed handler
    #include /usr/local/nginx/conf/pagespeed.conf;
    #include /usr/local/nginx/conf/pagespeedhandler.conf;
    #include /usr/local/nginx/conf/pagespeedstatslog.conf;
    
      # limit_conn limit_per_ip 16;
      # ssi  on;
    
      access_log /home/nginx/domains/gear.com.pk/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/gear.com.pk/log/error.log;
    
      root /home/nginx/domains/gear.com.pk/public;
    
      # prevent access to ./directories and files
      location ~ (?:^|/)\. {
       deny all;
      } 
    
      location / {
    
    # block common exploits, sql injections etc
    #include /usr/local/nginx/conf/block.conf;
    
      # Enables directory listings when index file not found
      #autoindex  on;
    
      # Shows file listing times as local time
      #autoindex_localtime on;
    
      # Enable for vBulletin usage WITHOUT vbSEO installed
      # More example Nginx vhost configurations at
      # http://centminmod.com/nginx_configure.html
      #try_files        $uri $uri/ /index.php;
    
      }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }
    
    So the hostname in my virtual.conf is not similar/same as my first domain.
     
  12. eva2000

    eva2000 Administrator Staff Member

    30,161
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    7:10 PM
    Nginx 1.13.x
    MariaDB 5.5
    wrong nginx vhost edit
    for

    Code (Text):
    server {
               listen   87.98.143.0:80;
    #            server_name gear.com.pk;
    #            return 301 $scheme://www.gear.com.pk$request_uri;
          }
    
    server {
      server_name gear.com.pk www.gear.com.pk;
    


    should be
    Code (Text):
    server {
    #            listen   87.98.143.0:80;
    #            server_name gear.com.pk;
    #            return 301 $scheme://www.gear.com.pk$request_uri;
          }
    
    server {
      listen   87.98.143.0:80;
      server_name gear.com.pk www.gear.com.pk;
    

    if you define a server{} context without listen, it uses default main ip instead

    also see Getting Started Guide step 1 for proper main hostname setup
     
    • Like Like x 1
  13. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    5:10 AM
    1.13.x
    MariaDB 10.1.x
    @eva2000 I wanted to ask, but I forgot before...

    For each new dedicated IP, do we need to add it to the hosts file?
    Code:
    xxx.xxx.xxx.xxx  server.myserver.com  server
    xxx.xxx.xxx.xxx  mydomain.com
    xxx.xxx.xxx.xxx  anotherdomain.com
    I thought I read somewhere on another site that when you add an ip you need to add it to the hosts file.
     
  14. eva2000

    eva2000 Administrator Staff Member

    30,161
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    7:10 PM
    Nginx 1.13.x
    MariaDB 5.5
    no really needed as that will bypass local DNS resolution for your domain so when you do a curl, wget, dig or trace from your server to your mydomain.com it will look to /etc/hosts file for DNS resolution to the ip. If you change your mydomain.com ip at DNS level, and forget to edit /etc/hosts then all those curl etc commands look up your old IP and not updated one. Though /etc/hosts is good for previewing your domain before updating DNS officially/publicly.
     
    • Informative Informative x 1
  15. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    5:10 AM
    1.13.x
    MariaDB 10.1.x
    FYI: OVH Failover IP is just a fancy name for an IP that isn't the main server ip.
     
  16. Jimmy

    Jimmy Premium Member Premium Member

    1,114
    247
    63
    Oct 24, 2015
    East Coast USA
    Ratings:
    +596
    Local Time:
    5:10 AM
    1.13.x
    MariaDB 10.1.x
    Everything always worked without adding it to the file. Figured I'd ask here, seemed like a good thread / time to ask. ;)
     
  17. Afaq

    Afaq Member

    46
    1
    8
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    2:10 PM
    ^
    Made the change. Now, its working fine. Thanks!
     
  18. RB1

    RB1 Active Member

    281
    72
    28
    Nov 11, 2016
    California
    Ratings:
    +119
    Local Time:
    2:10 AM
    Nginx 1.13.x
    MariaDB 10.1.x
    You don't need to add secondary IPs in the ifcfg-eth0 file?
     
  19. eva2000

    eva2000 Administrator Staff Member

    30,161
    6,785
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +10,136
    Local Time:
    7:10 PM
    Nginx 1.13.x
    MariaDB 5.5
    great :)

    if you follow Network IP Aliasing | OVH Docs you should be fine
     
  20. Afaq

    Afaq Member

    46
    1
    8
    Aug 5, 2015
    Ratings:
    +2
    Local Time:
    2:10 PM
    So the addition to the first IP worked fine. Now I am adding a new IP and that's not working. I edited the vhost file, added it to the server as well but its not pinging. Can anybody advice what could be the issue?