Welcome to Centmin Mod Community
Register Now

Nginx Vhost difficulties

Discussion in 'Nginx, PHP-FPM & MariaDB MySQL' started by Rdurty2, Nov 3, 2015.

  1. Rdurty2

    Rdurty2 Member

    38
    9
    8
    Oct 31, 2015
    Ratings:
    +12
    Local Time:
    3:15 PM
    1.11.4
    10.0.27
    This past weekend I followed the great Getting Started guide to install Centmin Mod. My plan is to move my Xenforo forum from shared hosting to my VPS and it's been an exciting adventure thus far and in a single weekend have learned so much.

    I do not want to set up DNS to point my domain name to the VPS until I have fully tested the Xenforo install on the VPS. I have edited my hosts file to the following:

    Code:
    vpsIPaddress      hostname.domain.com domain.com
    My vhost was created from the Centmin Menu and files uploaded to the appropriate "public" folder. I have also manually imported my Xenforo database.

    The issue is that when I enter my VPS IP address into the browser I just get the default Centmin Mod nginx page instead of my website. I cannot figure out why this is happening.

    Here is my vhost file for my domain:
    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   80;
                server_name MyDomainName.com;
                return 301 $scheme://www.MyDomainName.com$request_uri;
    #       }
    
    #server {
    #  server_name MyDomainName.com www.MyDomainName.com;
    
    # 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/MyDomainName/log/access.log combined buffer=256k flush=60m;
      error_log /home/nginx/domains/MyDomainName/log/error.log;
    
      root /home/nginx/domains/MyDomainName/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;
      index index.php index.html index.htm;
      try_files $uri $uri/ /index.php?$uri&$args;
      }
    
      location /internal_data/ {
         internal;
         allow 127.0.0.1;
         allow VPSipaddress;
         deny all;
         }
    
    location /library/ {
         internal;
         allow 127.0.0.1;
         allow VPSipaddress;
         deny all;
         }
    
      include /usr/local/nginx/conf/staticfiles.conf;
      #include /usr/local/nginx/conf/php.conf;
      include /usr/local/nginx/conf/php_disable_openbasedir.conf;
      include /usr/local/nginx/conf/drop.conf;
      #include /usr/local/nginx/conf/errorpage.conf;
      include /usr/local/nginx/conf/vts_server.conf;
    }                           
     
  2. Rdurty2

    Rdurty2 Member

    38
    9
    8
    Oct 31, 2015
    Ratings:
    +12
    Local Time:
    3:15 PM
    1.11.4
    10.0.27
    I was able to figure out the issue.

    My entries within the hosts files, both local and server were incorrect.

    They should have been:

    Code:
    VPSipAddress     www.domain.com  domain.com
     
    • Like Like x 1
  3. Sunka

    Sunka Active Member

    888
    230
    43
    Oct 31, 2015
    Rijeka, Croatia
    Ratings:
    +376
    Local Time:
    9:15 PM
    Nginx 1.13.3
    MariaDB 10.1.24
    where are that host files?
    etc/hosts ?
     
  4. Rdurty2

    Rdurty2 Member

    38
    9
    8
    Oct 31, 2015
    Ratings:
    +12
    Local Time:
    3:15 PM
    1.11.4
    10.0.27
    You are correct, on the server /etc/hosts
     
    • Informative Informative x 2
  5. eva2000

    eva2000 Administrator Staff Member

    28,942
    6,570
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +9,750
    Local Time:
    5:15 AM
    Nginx 1.13.x
    MariaDB 5.5
    glad you sorted it out

    for local windows pc edit hosts file edit also check out Hostsman app HostsMan - abelhadigital.com