reverse proxying towards various hardware devices

Maxim Dounin mdounin at
Sat Jan 23 21:42:12 MSK 2010


On Sat, Jan 23, 2010 at 04:45:07PM +0100, Paul Swielingen wrote:

> Hi all,
> I need some help with NGINX reverse proxying setup.
> The problem: make several devices accessible through a single IP
> address.
> my current configuration works:
> 1) For some devices: fine
> 2) For other devices: for a large part
> 3) For still other devices: hardly
> I analyzed the reason for 2) and 3) above and it comes down to: as soon
> as such a device returns a page with links that starts with a / clicking
> the link fails.  The reason for this is that the reverse proxy no longer
> recognizes the request as destined for the particular device.
> The relevant part from my nginx.conf file:
>   server {
>     listen;
>     location / {
>       root   /var/mine/data;
>       index  index.html;
>       }
>     location /spa3000-1/ { # forward to device
>       proxy_pass;
>       }
> ...
> similar configs for other devices
> ...
>     }
> I am aware that I could destine all these devices to their own port but
> I don't want to do that because securing them will become very
> difficult. Therefore I don't want to take that path.
> I know of the existence of referrers but I do not understand how to
> approach using that. Anybody can help me?

It's up to the device in question to form correct links on pages 
it returns.  If it doesn't do so - some limited changes may be 
done by sub filter module.  But it's not really a solution as it's 
not able to parse and interpret all of the returned code (even if 
teach it to parse html - what to do with broken html, javascript, 
css, xml+xslt and so on?).

So the only generic solution is to use separate hosts (or ports).  
You may still proxy them via nginx, i.e. write something like 

    server {

        location / {
            proxy_set_header Host $host;

and make sure device thinks it's called "" while 
this name in fact points to nginx server.

Maxim Dounin

More information about the nginx mailing list