How to Use OpenResty (Step-by-Step Guide)

A guide to using OpenResty for web server configuration, focusing on GZIP settings and basic operations.

Feb 7, 2025 · 1 min read · 170 Words · -Views -Comments · Programming
Deployment & Operations 🇨🇳 阅读中文版
Read with AI

Choose an AI assistant

ChatGPT Open in a new tab with the article link and prompt
Claude Copy the prompt, then open Claude

Open Claude
Trouble reading the article?

If the prompt is missing, copy the full prompt below into your AI assistant. If the AI cannot read the article, paste the visible passage you want to discuss and add your question.

Recently, I needed to modify the GZIP configuration for a web service. After checking the network, I noticed the response header showed server:openresty/1.21.4.1, which revealed that the gateway was using OpenResty. After confirming with the backend team, I needed to modify the GZIP configuration, which required some understanding of OpenResty.

What is OpenResty

OpenResty is a web server based on nginx that integrates nginx’s powerful performance with Lua’s dynamic capabilities.

Modifying GZIP Configuration in OpenResty

OpenResty’s GZIP configuration is similar to nginx’s configuration, primarily using the gzip directive.

nginx configuration path: /usr/local/openresty/nginx/conf/nginx.conf

gzip on;
gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
gzip_min_length 256;

Testing Configuration

In practice, you should first test if the configuration is correct before restarting.

openresty -t

Restarting OpenResty

openresty -s reload

Checking OpenResty Version

openresty -v

Final Thoughts

  1. So far, I’ve only worked with OpenResty’s GZIP configuration. I’ll add more when I encounter other configurations.
  2. As of now, I still prefer Caddy’s configuration approach - it’s more straightforward and clear.
Authors
Developer, digital product enthusiast, tinkerer, sharer, open source lover