Step-by-Step Guide to Adding a New GTM Server Host in Ubuntu 22
Table of Contents
Congratulations! You’ve about to unlock the potential of server-side tracking with GTM server. By following this comprehensive guide, you’ve accomplished the following:
- Established a robust foundation: Your new GTM server on Ubuntu 22 is ready to empower your web analytics and marketing strategies.
- Gained unparalleled control: You now have complete ownership over your data collection and processing, ensuring compliance and security.
- Embraced enhanced privacy: By implementing server-side tracking, you’re mitigating risks associated with traditional client-side tracking and upholding GDPR regulations.
- Unlocked limitless possibilities: With newfound flexibility, you can effortlessly implement custom tags and advanced configurations to tailor your tracking to your specific needs.
This achievement marks the beginning of an exciting journey. As you continue to explore the capabilities of GTM server and server-side tracking, you’ll be well-equipped to unlock a wealth of valuable insights and optimize your website’s performance.
Step 1: Update DNS Configuration
- Open your DNS management console or contact your DNS provider.
- Create two DNS records for the domains “gtm” and “gtmp” and point them to the IP address of your server
- Create an “A” record for “gtm.example.com” with the IP address of your server
- Create an “A” record for “gtmp.example.com” with the IP address of your server
- Save the DNS configuration.
Step 2: Stop Nginx
- Connect to your server via SSH or open a terminal.
- Execute the following command to stop the Nginx server:
sudo service nginx stop
Step 3: Generate SSL Certificates
- Make sure Nginx is stopped before generating the certificates.
- Execute the following command to generate SSL certificates for the domains:
sudo certbot certonly --standalone -d gtm.example.com,gtmp.example.com --agree-tos --register-unsafely-without-email
3. Wait for the certificate generation process to complete.
Step 4: Configure Nginx for your GTM server gtm.example.com
1. Change to the Nginx sites-available directory:
cd /etc/nginx/sites-available
2. Open the configuration file for “gtm.example.com” using the Nano text editor:
sudo nano gtm.example.com
3. Copy and paste the following configuration into the file:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name gtm.example.com;
gzip on;
gzip_disable "msie6";
gzip_min_length 100;
#### Lets Encrypt ACME Challenge
location ^~ /.well-known/acme-challenge/ {
allow all;
root /var/lib/letsencrypt/;
default_type "text/plain";
try_files $uri =404;
}
#### Lets Encrypt ACME Challenge
#### Proxy to docker backend with GTM ####
location / {
proxy_pass http://localhost:8080;
}
ssl_certificate /etc/letsencrypt/live/gtm.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/gtm.example.com/privkey.pem;
}
4. Save the file by pressing Ctrl + X
, then Y
, and finally Enter
.
Step 5: Configure Nginx for gtmp.example.com
1. Create the configuration file for “gtmp.example.com” using the Nano text editor:
sudo nano gtmp.example.com
2. Copy and paste the following configuration into the file:
server {
listen 443 ssl http2;
listen [::]:443 ssl http2;
server_name gtmp.example.com;
gzip on;
gzip_disable "msie6";
gzip_min_length 100;
#### Lets Encrypt ACME Challenge
location ^~ /.well-known/acme-challenge/ {
allow all;
root /var/lib/letsencrypt/;
default_type "text/plain";
try_files $uri =404;
}
#### Lets Encrypt ACME Challenge
#### Proxy to docker backend with GTM ####
location / {
proxy_pass http://localhost:8079;
}
ssl_certificate /etc/letsencrypt/live/gtm.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/gtm.example.com/privkey.pem;
}
3. Save the file by pressing Ctrl + X
, then Y
, and finally Enter
.
Step 6: Create Symbolic Links
1. Create symbolic links for the configuration files in the sites-enabled directory:
cd /etc/nginx/sites-enabled/
sudo ln -s ../sites-available/gtm.example.com ./
sudo ln -s ../sites-available/gtmp.example.com ./
Step 7: Restart Nginx
1. Start the Nginx server using the following command:
sudo service nginx restart
Congratulations! You have successfully set up the server with Nginx and SSL certificates for the domains gtm.example.com and gtmp.example.com. Nginx will now serve the requests for these domains, proxying them to the specified backend services. The SSL certificates ensure secure communication over HTTPS.
Step 8: Restart Docker on your new GTM server
docker stop gtm-preview
docker stop gtm-live
docker start gtm-preview
docker start gtm-live
We’re also on Facebook! Like our page to stay up to date with all the news about our services. Don`t forget to check out our other blog articles here for more useful information.
Leave a Reply