Last Updated on September 21, 2023 EDT by Jordan
Content Error or Suggest an Edit
Notice a grammatical error or technical inaccuracy? Let us know; we will give you credit!
DISCLAIMER
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.
Archived
This article is archived, you can now create a default site at GridPane using the following article https://gridpane.com/kb/set-a-gridpane-site-as-the-default-site-for-nginx/
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.managingwp.io and not just managingwp.io 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.managingwp.io
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.managingwp.io to 192.168.0.1
- Create an A record called *.srv01.managingwp.io and point it to 192.168.0.1
The second record is called a wildcard, which will ensure anything.srv01.managingwp.io 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.managingwp.io 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.
<meta http-equiv = "refresh" content = "2; url = https://managingwp.io" />
Modify NGINX config for the site
This step will enable the new site srv01.managingwp.io to be served as the default site for anyone requests that don’t match an existing configuration.
Edit the NGINX config for the srv01.managingwp.io site as the root user
vi /etc/nginx/sites-available/srv01.managingwp.io
Then you will want to modify the following two lines, they will be in separate locations in the configuration file.
Warning
Make a backup of said file just in-case you make a typo or something else dangerous.
listen 80; listen [::]:80; listen 443 ssl http2; listen [::]:443 ssl http2;
Now add word default to the end of each line before the semi-colon like so.
listen 80 default; listen [::]:80 default; listen 443 ssl http2 default; listen [::]:443 ssl http2 default;
Confirm NGINX likes what you’ve done by running the following command.
root@srv01:~# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok nginx: configuration file /etc/nginx/nginx.conf test is successful
And then restart NGINX.
root@srv01:~# systemctl reload nginx
Keeping the change persistent
Unfortunately, if you make any modifications to the srv01.managingwp.io 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
root@srv01:~# chmod 444 /etc/nginx/sites-available/srv01.managingwp.io
And you should be set!
Archived
This article is archived, you can now create a default site at GridPane using the following article https://gridpane.com/kb/set-a-gridpane-site-as-the-default-site-for-nginx/
Last Updated on September 21, 2023 EDT by Jordan