Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

I am trying to set up a reverse proxy to give access to several internal web servers from the internet. I have configured some name based virtual hosts with reverse proxy (I enabled proxy and proxy_http modules).

So far so good...

One of the servers happen to be a wordpress site. Wordpress will generate html pages containing its internal url (for css, etc...). So I am trying to use the proxy_html module to rewrite those urls on the reverse proxy. But I fail miserably.

Most of the documentation on the internet refer to the latest version of the module, but 12.04 ships with version 3.0.1, and I can't figure out how to make it work.

Here is what I have put in my virtual host conffile:

<VirtualHost *:80>
        ProxyPreserveHost On
        ProxyRequests Off
        ServerName example.com
        ServerAlias www.example.com
        ProxyPass / http://192.168.1.12/
        ProxyPassReverse / http://192.168.1.12/
        ProxyHTMLURLMap http://192.168.1.12 http://www.example.com
        #SetOuputFilter INFLATE;proxy-html;DEFLATE
</VirtualHost>

I expect any url containing http://192.168.1.12 produced by wordpress on server 192.168.1.12 to be translated into http://www.example.com. This does not happen. I have tried to add other directives, but all failed:

ProxyHTMLEnable On

fails. It seems to be too new and not supported by this version of the module.

SetOuputFilter INFLATE;proxy-html;DEFLATE

fails also. Maybe I am missing a module to do that ? I have tried adding a2enmod filter, but it does not work either...

Well, can someone enlighten me on that ?

EDIT Noticed the mistyping in SetOuputFilter? A t is missing... So SetOutputFilter proxy-html is the way to go to get proxy_html working on 12.04. But I'll rather go for the other solution: tell wordpress to behave according to its public name and generate right urls from the beginning.

share|improve this question

1 Answer 1

up vote 1 down vote accepted

I have always told Wordpress that my site address was example.com (so that none of the urls created by wordpress have an ip address) and then had my proxy config look something like this:

    ServerName example.com

    ProxyRequests Off
    ProxyPreserveHost On
    ProxyPass / http://192.168.1.1
    ProxyPassReverse / http://192.168.1.1

keeps it simple.

share|improve this answer
    
Yes, I might finally do that... but then, if I access the site directly from the LAN (without going through the reverse proxy) it fails to load the css... –  alci Feb 13 '13 at 16:33
    
Add a DNS entry to your router (assuming it supports it) mapping the domain name to the servers internal ip address. –  Luis Flores III Feb 13 '13 at 16:46
    
Ok, I buy your first solution. You're right, I'll keep it sipmle. –  alci Feb 13 '13 at 17:05
    
Glad I could help. –  Luis Flores III Feb 13 '13 at 17:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.