How I Created an Install Script for My Application with Chat GPT

Posted by Brian Porter on March 23, 2023

I recently needed to create an install script for my application, which involved setting up Nginx to proxy traffic to a backend server over SSL. As I had never done this before, I decided to seek the help of Chat GPT, a large language model developed by OpenAI that is capable of generating human-like responses to text prompts.

To get started, I asked Chat GPT for guidance on installing Nginx on Debian 11. Here’s an example of the prompt I used:

Me: Hi Chat GPT, can you help me install Nginx on Debian 11?

In response, Chat GPT provided me with the necessary commands to install Nginx on Debian 11. Here’s an example of the response I received:

Chat GPT: Sure, here's the command to install Nginx on Debian 11:

sudo apt update
sudo apt install nginx

Next, I asked Chat GPT how to generate a self-signed SSL certificate for Nginx. Here’s an example of the prompt I used:

Me: Hi Chat GPT, can you help me generate a self-signed SSL certificate for Nginx?

In response, Chat GPT provided me with the necessary commands to generate a self-signed SSL certificate for Nginx. Here’s an example of the response I received:

Chat GPT: Sure, here's the command to generate a self-signed SSL certificate for Nginx:

sudo openssl req -x509 -nodes -days 365 -newkey rsa:2048 -keyout /etc/nginx/ssl/nginx.key -out /etc/nginx/ssl/nginx.crt -subj "/C=US/ST=CA/L=San Francisco/O=My Company/CN=mydomain.com"

After generating the SSL certificate, I asked Chat GPT how to configure Nginx to proxy traffic to a backend server over SSL. Here’s an example of the prompt I used:

Me: Hi Chat GPT, can you help me configure Nginx to proxy traffic to a backend server over SSL?

In response, Chat GPT provided me with the necessary configuration file settings for Nginx. Here’s an example of the response I received:

Chat GPT: Sure, here's the configuration file settings for Nginx to proxy traffic to a backend server over SSL:

server {
    listen 443 ssl;
    server_name mydomain.com;

    ssl_certificate /etc/nginx/ssl/nginx.crt;
    ssl_certificate_key /etc/nginx/ssl/nginx.key;

    location / {
        proxy_pass http://localhost:8080;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection 'upgrade';
        proxy_set_header Host $host;
        proxy_cache_bypass $http_upgrade;
    }
}

As I iteratively worked through the suggestions provided by Chat GPT, I encountered several issues, such as errors in the suggested commands and incorrect configuration file settings. However, with some trial and error, I was able to get everything working as expected.

In the end, I was able to create a working install script for my application by using Chat GPT as a guide. While there were some hiccups along the way, the guidance provided by Chat GPT was invaluable in helping me understand the process and get everything set up correctly.

If you’re new to a particular technology or process and need some guidance, I would definitely recommend using Chat GPT to help you get started

If you made it this far, you may as well follow me on LinkedIn: Follow Brian Porter