Welcome to Centmin Mod Community
Register Now

Nginx How do you run test server?

Discussion in 'Install & Upgrades or Pre-Install Questions' started by modder, Mar 29, 2020.

  1. modder

    modder Member

    123
    16
    18
    Dec 6, 2019
    Ratings:
    +27
    Local Time:
    8:48 AM
    Currently I'm still developing my xenforo with centmod as the base.

    I'm wondering how I can test new features or debug anything once it's go production.

    I don't want to make any test or changes on the production server directly.

    So an ideal way is to take a snapshot of production server, say domain1.com and then restore it to a test server and get a different domain name, say domain2.com for it. And I just need to work on domain2.com, i can mess around it, if something goes wrong, i can just restore the snapshot again.

    1) Question, how can I quickly change the domain name of a webserver for my purpose?

    2) Is there a better way for testing/developing the server once it goes online?


    Thanks.
     
  2. eva2000

    eva2000 Administrator Staff Member

    55,209
    12,251
    113
    May 24, 2014
    Brisbane, Australia
    Ratings:
    +18,829
    Local Time:
    10:48 AM
    Nginx 1.27.x
    MariaDB 10.x/11.4+
    Just setup the domains you want via centmin.sh menu option 2 as outlined at Nginx Vhost & NSD DNS Setup - CentminMod.com LEMP Nginx web stack for CentOS They aren't live unless you edit your domain's DNS to point to centminmod server's IP address so will no interfere with your live domain operation.

    Then edit each domain's vhost file at /usr/local/nginx/conf/conf.d/newdomain.com.conf and /usr/local/nginx/conf/conf.d/newdomain.com.ssl.conf (if you set yes to ssl) and add to server_name listing additional domain names you want to test from i.e. test.newdomain.com.

    would change from

    Code:
    server {
      server_name newdomain.com www.newdomain.com;
    to

    Code:
    server {
      server_name newdomain.com www.newdomain.com test.newdomain.com;
    then only update DNS for test.newdomain.com to point to centminmod server's IP address. Then after testing is done and you want to switch live domain to centminmod copy, just update DNS for newdomain.comto point to centminmod server's IP address as well :)

    OR

    If you want to preview newdomain.com on new centminmod server without updating DNS, on Windows PC edit your windows HOSTS file at c:\Windows\System32\Drivers\etc\hosts (see guide at Modify your hosts file | Knowledge Center | Rackspace Hosting or install Hostman app HostsMan which can manage the file too and allows easy dns flushing when you make changes to the hosts file.

    c:\Windows\System32\Drivers\etc\hosts contents to preview without DNS update
    Code:
    centminmodserver-ip-address newdomain.com
    to disable preview comment it out and flush dns for your system
    Code:
    #centminmodserver-ip-address newdomain.com
    Hostsman app to flush dns and edit the c:\Windows\System32\Drivers\etc\hosts file

    And for MacOS users there's How to edit your Mac's Hosts file and why you would want to
     
  3. modder

    modder Member

    123
    16
    18
    Dec 6, 2019
    Ratings:
    +27
    Local Time:
    8:48 AM
    Are you talking about making a virtual web server in the same server as a test drive?

    What if I use a separate VPS and restore the snapshot made from domain1.com (VPS1) and just change the domain name to another one, e.g. domain2.com. After the test is done, change its domain name to domain1.com and change DNS point to it. In the process, I'll have to change the server_name attribute to new domain name and also the SSL crt, key, etc. And maybe also some API keys..

    But the downside is I will lose data between the snapshot is made and switching over to live. That really depends on how much time I'll need to spend on the test.. maybe days!

    What's the best way to do it then? How do people usually do it to make it looks like no data loss without minimal downtime?
     
    Last edited: Mar 30, 2020