NGINX Chats with ChatGPT and Gets Mixed Results from the Hottest Bot du Jour

by

in
Person chatting about NGINX with ai chatbot

In the short time since its debut, ChatGPT has taken the technology world by storm. Created by AI research and deployment company OpenAI, ChatGPT is a browser‑based chatbot that uses OpenAI’s natural language models to learn how to interact with humans in what OpenAI calls a “conversational way”. It can do amazing things, like write songs and even Shakespearean sonnets. Programmers have been blown away by the detail of some responses ChatGPT provided to basic questions.

But some clouds have appeared. The Q&A site StackOverflow has temporarily banned responses generated by ChatGPT because too many were incorrect. And some users reported responses that were clearly incorrect or simply made up for oddball and even mainstream questions.

We are huge fans of new ways to help our users and community learn quickly and answer questions. We were curious to see whether ChatGPT provides quality answers for NGINX‑related questions and gave it a quick test drive.

Hey ChatGPT…

We asked ChatGPT four questions. We show ChatGPT’s answer and assess its accuracy.

Question 1

Question: What is NGINX?

Answer: NGINX is a web server that can be used to serve websites and applications. It is known for its high performance and stability, making it a popular choice for many websites and applications. NGINX can also be used as a reverse proxy, load balancer, and HTTP cache. It is open source software, and is widely used on the Linux operating system.

Accuracy: Basically accurate. It does fail to mention API gateway as an additional common use case.

Question 2

Question: Does NGINX Open Source have a WAF?

Answer: Yes, the open source version of NGINX includes a web application firewall (WAF) module. The NGINX WAF is based on the ModSecurity open source WAF, which provides a flexible and powerful rules engine for protecting your web applications from common vulnerabilities such as SQL injection and cross‑site scripting attacks. The NGINX WAF can be configured to provide both positive and negative security models, allowing you to specify exactly which requests should be allowed and which should be blocked. However, keep in mind that the open source version of NGINX does not include support for the WAF module, so if you need help setting it up or using it, you will need to rely on community support or consult with an expert.

Accuracy: A mixed bag. The NGINX Open Source software available at nginx.org does not include a WAF, either as source code, in the precompiled binaries, or as a prebuilt dynamic module. However, it is possible to build a WAF for NGINX Open Source based on the open source ModSecurity WAF, in the form of a dynamic module built from the libmodsecurity library provided by Trustwave’s SpiderLabs. We provide instructions on our blog. Without these details, however, a reader trying to track down the WAF based on this answer might find it difficult to find the needed resources and is likely to be confused and frustrated.

On the other hand, the description of the ModSecurity WAF is informative, and it is true that as open source software the ModSecurity WAF dynamic module is not supported. (For completeness, we’ll mention that F5 NGINX did have a supported WAF based on ModSecurity for NGINX Plus, but it is no longer available for sale and will reach end of life in 2024. Instead, we now offer NGINX App Protect WAF to our paid subscribers as an add‑on to NGINX Plus and other products.)

Question 3

Question: Tell me how to configure NGINX

Answer: To configure NGINX, you will need to edit its configuration file, which is typically called nginx.conf and is located in the conf directory inside the NGINX installation directory.

The configuration file is written in the form of directives, which are instructions that tell NGINX how to behave. Each directive is specified on a new line, and typically takes the form directive_name directive_value;.

Here is an example configuration file that shows some common directives:

# This is a comment

# The number of worker processes to run.
# It is usually best to set this to the number of CPU cores on the server
worker_processes 4;

# The directory where the log files will be stored
error_log /var/log/nginx/error.log;

# The default server, which will be used if no other server matches 
# the request
server {
    # The listen directive specifies the port that the server will 
    # listen on
    listen 80;

    # The root directive specifies the root directory for the server
    root /var/www/html;

    # The server_name directive specifies the server's hostname
    server_name example.com;

    # The location directive specifies a URL pattern and associated 
    # handling rules
    location / {
        # This directive specifies that requests for the root URL 
        # should be handled by the index.html file in the root directory
        index index.html;
    }
}

You can find more information about the various directives that are available in the NGINX documentation, which you can access at https://nginx.org/en/docs/.

Accuracy: Well, it’s pretty good as far as it goes (the most dubious statement is that nginx.conf is located in the conf directory inside the NGINX installation directory, which applies at best only to certain OS vendor distributions). The descriptions of directives in the sample configuration are correct, but the overall structure isn’t complete, particularly in that it doesn’t enclose the server block in the http{} context as required. The sample configuration is also so sketchy that it’s not really useful. But given the wide variety of use cases which NGINX supports, it’s probably not reasonable to expect a complete answer.

However, this answer itself raises an interesting question – what sources is ChatGPT using for its answers? Neither the text nor the configuration in this answer is taken directly from documentation on nginx.org or nginx.com, and a Google search for several phrases in the answer yields no matches from any source. ChatGPT includes a link to official NGINX documentation, which begs the question why the answer itself isn’t derived from that source.

Question 4

Question: What are the Top 10 NGINX Configuration Mistakes?

Answer: Could not provide an answer.

Accuracy: This was a softball question based on the titles of a blog post and corresponding webinar, both of which are very similar to the question. The fact that ChatGPT could not answer in any way underlines how it’s not to be confused with Google, which has a much broader index and found the blog. In fact, Google not only returned the blog as the first result – it provided the first seven items from the summary list that’s in the intro of the blog itself.

Screenshot of Google search results for 'Top 10 NGINX Configuration Mistakes'

Conclusion

ChatGPT is a super powerful and super fun technology. It does a fantastic job answering some questions in a format that is more conversational than other bots. In some instances, it appears to do a good job providing detailed responses to programming questions. But its coverage remains spotty and your mileage will certainly vary with regard to NGINX information. Naturally, the best info on NGINX is at nginx.org and docs.nginx.com. But stay tuned as we continue to play with ChatGPT and see how it develops.

What’s your experience with ChatGPT? Join the conversation on the NGINX Community Slack to discuss with other NGINX power users how they are using this, and other, OpenAI tools.