Reverse Proxy to your lan – inc wordpress hack

1. Name server

Create name server entry pointing to your wan address

your.external-name.com  A  1.2.3.4

2. Router

Create a port forward  (on a specific port if required to a specific port)

WAN (1.2.3.4) -> forward http traffic to lan 192.168.0.12 port 8113

Apache 2.2 or higher

3.  Enable modules

LoadModule proxy_module modules/mod_proxy.so
LoadModule proxy_http_module modules/mod_proxy_http.so

4. Listen on the incoming port

httpd.conf : Listen 8113

5. httpd-vhosts.conf

httpd-vhosts.conf  : Add in

NameVirtualHost *:8113

 

6. Vhosts container

<VirtualHost *:8113>
ProxyPass / http://your.local.domain/
ProxyPassReverse / http://your.local.domain/

<Location />
Order Deny,Allow
Deny from all
# Allow from all
Allow from 192.168.0  # enable / disable access
</Location>

ServerName your.external-name.com
ErrorLog “logs/proxy-error-log”
CustomLog “logs/proxy-access-logs” common
</VirtualHost>

7. WordPress – wp-config.php

Hack to rewrite urls on the fly.

if($_SERVER[‘HTTP_X_FORWARDED_HOST’] == ‘your.external-name.com:8113’ )
{
define(‘WP_SITEURL’,’http://your.external-name.com:8113′);
define(‘WP_HOME’,’http://’your.external-name.com:8113′);
}
else
{
define(‘WP_SITEURL’,’http://your.local.domain’);
define(‘WP_HOME’,’http://your.local.domain’);
}

8. Enjoy !

 

×

Comments are closed.