问题原文
原帖链接 · simplfuzz · CC BY-SA 3.0
I have a single machine running nginx serving http traffic for multiple domains(using same Lua codebase). For some of the domains I would like to enable gzip compression. Is it possible to enable gzip compression for specific set of domains? How?
已采纳解答
原帖链接 · Drifter104 · CC BY-SA 3.0
Absolutely if you take a look at the documentation you can see that it is acceptable to place gzip in any of the following levels http, server, location, if in location and as the domain is defined at the server level using server_name we can place gzip along side it.
First check your nginx.conf file for gzip on; if it is present remove it.
You then need to create a conf file and define where you want to use gzip.
server {
server_name www.myexample.com;
listen 80;
gzip off;
}
server {
server_name www.myotherexample.com;
listen 80;
gzip on;
}
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
