1

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.

1 Answer 1

1

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.

5
  • 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, 2013 at 16:33
  • Add a DNS entry to your router (assuming it supports it) mapping the domain name to the servers internal ip address. Feb 13, 2013 at 16:46
  • Ok, I buy your first solution. You're right, I'll keep it sipmle.
    – alci
    Feb 13, 2013 at 17:05
  • Glad I could help. Feb 13, 2013 at 17:11
  • Its works for http urls but For https its not working please advise Feb 6, 2017 at 8:06

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .