# Nginx replacing body content

**URL:** <https://www.ruby-forum.com/t/nginx-replacing-body-content/197690>\
**Category:** NGINX\
**Created:** [October 19, 2010, 12:20am UTC](https://www.ruby-forum.com/t/nginx-replacing-body-content/197690 "2010-10-19T00:20:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/77aa72/32.png) [@Dobai-Pataky\_BSSSSl](https://www.ruby-forum.com/u/Dobai-Pataky_BSSSSl)\
**Post date:** [October 19, 2010, 12:20am UTC](https://www.ruby-forum.com/t/nginx-replacing-body-content/197690/1 "2010-10-19T00:20:06Z")

</div>

Hello all:

So I have been using nginx for a while now for various types of proxying  
and SSL acceleration all with great success. However now I need to  
replace specific content within an html body. I have been trying to get  
the HttpSubsModule to work as It appears to do what I am looking for.  
However I have not been able to get it to match or replace any content  
whatsover. I believe I have the module compiled and loading.

Here is a snippit of my config, my goal would be to replace all  
instances of ‘cat’ with the word dog.

server { #server80  
listen 80;  
server\_name [community.qnx.com](http://community.qnx.com);  
access\_log /var/log/nginx/proxy.access.log;  
##error\_log /var/log/nginx/proxy.error.log debug;

location / {  
subs\_filter\_types text/html;  
subs\_filter cat dog i;

```
         #proxy_set_header X-Forwarded-Host $host;
         #proxy_set_header X-Forwarded-Server $host;
         #proxy_set_header X-Forwarded-For 

```

$proxy\_add\_x\_forwarded\_for;  
proxy\_pass [http://internal.site.com:80/](http://internal.site.com:80/);  
#proxy\_redirect off;  
}

} #server80

Regards.  
Duane

---

<div class="post-metadata">

**Author:** ![dmorin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@dmorin](https://www.ruby-forum.com/u/dmorin)\
**Post date:** [October 19, 2010, 4:05am UTC](https://www.ruby-forum.com/t/nginx-replacing-body-content/197690/2 "2010-10-19T04:05:56Z")

</div>

Duane M. at 2010-10-19 6:18 wrote:

> Hello all:
> 
> So I have been using nginx for a while now for various types of proxying  
> and SSL acceleration all with great success. However now I need to  
> replace specific content within an html body. I have been trying to get  
> the HttpSubsModule to work as It appears to do what I am looking for.  
> However I have not been able to get it to match or replace any content  
> whatsover. I believe I have the module compiled and loading.

Do you compress your pages in the backends? If so, do not compress the  
content.  
Does the page’s type is text/html?

> ```
> }
> 
> ```
> 
> nginx mailing list  
> [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> [mailman.nginx.org archive](http://nginx.org/mailman/listinfo/nginx)

–  
Weibin Y.

---

<div class="post-metadata">

**Author:** ![dmorin](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/f0a364/32.png) [@dmorin](https://www.ruby-forum.com/u/dmorin)\
**Post date:** [October 19, 2010, 6:42am UTC](https://www.ruby-forum.com/t/nginx-replacing-body-content/197690/3 "2010-10-19T06:42:12Z")

</div>

Hello Weibin:

Occams Razor, thanks It turns out mod\_deflate was enabled, I disabled  
it and moved the gzip options into nginx now all the cats are dogs.

Thanks very much  
Duane
