The following commands change how your GridPane server functions. This may void any support provide by GridPane, use at your own discretion. If you contact GridPane support, inform them that you made these changes.
Table of Contents
There is no default site configured for GridPane servers within NGINX, this can become a problem when a site is pointed to your server but no longer exists as a site on said server. There are also other scenarios, such as not have SSL enabled for a site. Typically Chrome will redirect http:// sites automatically to https:// if it can connect to port 443 and is presented with an SSL Certificate.
In both scenarios, you’ll most likely see a site that’s configured on your server and not the site for the domain name you’re visiting. It’s usually the first configuration file within /etc/nginx/sites-enabled which is sorted by file name alphabetically.
Now, let’s say we don’t want that aaacarparts.com site to show up in instances where there’s a mis-configuration or when someone visits https://192.168.1.2 (your server’s IP address). Luckily, GridPane hasn’t set a default site for both port 80 and 443. So you can do this yourself easily.
Ensure your server has an appropriate hostname
First, you want to make sure that you name your servers appropriately, using a sub-domain such as srv01.wpinfo.net and not just wpinfo.net I’ll explain this one day.
You can use a domain name for a server, but honestly, it’s just my personal preference not to with years of systems administration behind me.
In this example, we will use srv01.wpinfo.net
Setup your server’s hostname in DNS
Now that you’ve chosen a name for your server, let’s point the DNS to it’s IP address. In this example, we’ll use 192.168.0.1 as the server.
- Create an A record pointing srv01.wpinfo.net to 192.168.0.1
- Create an A record called *.srv01.wpinfo.net and point it to 192.168.0.1
The second record is called a wildcard, which will ensure anything.srv01.wpinfo.net is pointed to 192.168.0.1
Why? Well, it services a couple of purposes which I can explain in another article. But it allows each domain or specific domains to have a temporary URL. But also allows you to generate sites for testing or whatever you like. I personally use these for development when I’m doing a handoff and not hosting the site.
Create a site for your server’s hostname in GridPane
Next, you will want to create a site in GridPane for srv01.wpinfo.net attached to the system user gridpane. You can create a new system user for this site, it’s totally personal preference.
You will want to enable SSL and whatever else you require to build a default page. I don’t use WordPress, I remove the install files and just put in an index.html in the root and use a meta tag for a browser redirect.
Modify NGINX config for the site
This step will enable the new site srv01.wpinfo.net to be served as the default site for anyone requests that don’t match an existing configuration.
Edit the NGINX config for the srv01.wpinfo.net site as the root user
Then you will want to modify the following two lines, they will be in separate locations in the configuration file.
Make a backup of said file just in-case you make a typo or something else dangerous.
Now add word default to the end of each line before the semi-colon like so.
Confirm NGINX likes what you’ve done by running the following command.
And then restart NGINX.
Keeping the change persistent
Unfortunately, if you make any modifications to the srv01.wpinfo.net site from the GridPane control panel. The changes you just made will be removed.
To have the changes persist, then chmod the file 444 like so
And you should be set!