Discover Centmin Mod today
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:
    10:49 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:
    10:49 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
     
  3. Sunka

    Sunka Well-Known Member

    1,150
    325
    83
    Oct 31, 2015
    Pula, Croatia
    Ratings:
    +525
    Local Time:
    3:49 AM
    Nginx 1.17.9
    MariaDB 10.3.22
    where are that host files?
    etc/hosts ?
     
  4. Rdurty2

    Rdurty2 Member

    38
    9
    8
    Oct 31, 2015
    Ratings:
    +12
    Local Time:
    10:49 PM
    1.11.4
    10.0.27
    You are correct, on the server /etc/hosts
     
  5. eva2000

    eva2000 Administrator Staff Member

    54,909
    12,240
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,811
    Local Time:
    12:49 PM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    glad you sorted it out

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